5

I am trying to learn about LocalAssetTransactor, but can't find much about xcm in general. I know there is a thorough blog post (https://polkadot.network/blog/xcm-the-cross-consensus-message-format/), but is there anything more detailed?

For example: can you explain the difference between darwinia set up and substrate-parachain-template in regard to the IsConcrete type?

2 Answers 2

4

Shawn Tabrizi's xcm workshop and video are a good start for learning how to implement XCM. I've also found that compiling and opening polkadots docs to access public documentation for XCM to be very useful too. It helps to make sense of all the different traits and components used in different xcm configurations. (I'm not sure there's a public site that hosts this documentation yet).

The LocalAssetTransactor type is an abstraction for the xcm-executor to transact assets on a local chain. This includes things like depositing assets, withdrawing assests, transferring assets, etc.

The documentation on the AssetTransactor type describes it as

How to withdraw and deposit an asset.

And the trait, TransactAsset required for the type AssetTransactor is described with

Facility for asset transacting.

This should work with as many asset/location combinations as possible. Locations to support may include non-account locations such as a MultiLocation::X1(Junction::Parachain). Different chains may handle them in different ways.

Can be amalgamated as a tuple of items that implement this trait. In such executions, if any of the transactors returns Ok(()), then it will short circuit. Else, execution is passed to the next transactor.

The CurrencyAdapter struct present in both the parachain-template and darwinia setup you're referencing implements this TransactAsset trait.

We can then learn that the second generic on the struct CurrencyAdapter implements a trait MatchesFungible which returns an Option<Balance> if there is a fungible asset matching IsConcrete on the system. The IsConcrete describes which asset we want to match. In parachain_template's case, IsConcrete is matching against the Relay chain asset (DOT/KSM/ROC), in Darwinia's case it is matching against Darwinias native asset. Therefore, the currency transactor will transact in Darwinia native currency on Darwinia, or in the relay chain's currency on parachain-template. If the currency in the MultiAsset does not match in either cases (i.e it's not Dot/Roc/Ksm or not Darwinia), the xcm transaction will error out.

Relay Chain location for parachain-templates 'isConcrete':

    pub const RelayLocation: MultiLocation = MultiLocation::parent();

Darwinia Location:

    pub AnchoringSelfReserve: MultiLocation = MultiLocation::new(
        0,
        X1(PalletInstance(<Balances as PalletInfoAccess>::index() as u8))
    );

Darwinia location has 0 parents and describes it's own balances pallet, which deals with operations for the native token. The naming for Darwinia's location may be a bit confusing, but it's referencing that Darwinia chain is the reserve ("Self Reserve") for it's own Darwinia token. "Anchoring" refers to the relative location type, as in the location from the perspective of Darwinia.

You can also learn a bunch by reading through docs other parachains have created for XCM. Moonbeams documentation is pretty good and i'm sure there are other parachain team docs out there too

4
  • 1
    thank you this is extremely useful for my understanding, and i hope others too. Dec 6, 2022 at 12:35
  • 1
    so if i use IsConcrete to match the Relay token, then i would need to make sure the sovereign account is funded? Dec 6, 2022 at 13:06
  • 1
    I'm not 100% sure what you're referencing but: The LocalAssetTransactor generally deals with assets in the XCM MultiAsset type itself, so it only touches the sovereign account if it's a reserve transfer in order to transfer to and from a sovereign account on a chain that is the reserve for a token. The sovereign account only needs to already be funded/exist if the reserve transfer contains a token that is not sufficient on its own, and therefore unable to create/keep an account alive.
    – insipx
    Dec 6, 2022 at 15:22
  • 1
    If you're talking about where to fees are coming from, the fees come out of the XCM MultiAsset sent in the message. So if you were to transfer 2 DOT from one chain to the parachain template, the user on parachain-template would receive 2 DOT minus fee
    – insipx
    Dec 6, 2022 at 15:24
2

I also highly recommend trappist if you want to play around with XCM. Follow the instructions in the README to setup a playground with zombienet and try out XCM with the polkadot JS app.

Your Answer

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

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