1

When sending Transact XCM Instruction from parachain A, how do I specify (or how does the xcm-executor know) the pallet / pallet id on the target Parachain B which contains the extrinsic to be executed, or is it not required?

for example. The following Transact Xcm message is sent from parachain A to execute an extrinsic called ping defined in the cumulus-ping pallet on Parachain B. In the xcm message below, I do not see the cumulus-ping pallet or the index of the cumulus-ping pallet specified in the XCM instruction. so how does XCM determine the pallet / module where the ping extrinsic on Parachain B is located? The code I attached below is from the cumulus repo here

// This is Parachain A, which sends the xcm message

send_xcm::<T::XcmSender>(
                    (Parent, Junction::Parachain(para.into())).into(),
                    Xcm(vec![Transact {
                        origin_kind: OriginKind::Native,
                        require_weight_at_most: Weight::from_parts(1_000, 1_000),
                        call: <T as Config>::RuntimeCall::from(Call::<T>::ping {
                            seq,
                            payload: payload.clone().to_vec(),
                        })
                        .encode()
                        .into(),
                    }]),
                ) 

// This is the runtime of patachain B which contains cumulus-ping pallet which has the ping extrinsic

construct_runtime! {
    pub enum Runtime where
        Block = Block,
        NodeBlock = generic::Block<Header, sp_runtime::OpaqueExtrinsic>,
        UncheckedExtrinsic = UncheckedExtrinsic,
    {
        System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
        ...
        Spambot: cumulus_ping::{Pallet, Call, Storage, Event<T>} = 99,
    }
}

1 Answer 1

1

In the XCM Transact instruction, the call operand is the SCALE-encoded transaction call to be applied. This implies that the first 2 bytes will encode the following info:

  • 1st byte is the pallet index the transaction is calling into.
  • 2nd byte is the function in the pallet the transaction is calling.

This way, the destination chain, once processing the received XCM message with the Transact instruction, can unequivocally identify the specific pallet and call to be executed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.