infrablockchain-docs
en
en
  • InfraBlockchain
    • Learn
      • Architecture
        • Architecture
        • Network Participants
        • Parachain
          • System Parachains
      • Protocol
        • System Token
        • Transaction Fee
        • Proof of Transaction
      • Substrate
        • Learn
          • Basic
            • Cryptography
            • Blockchain Basics
            • Consensus
            • Networks and Nodes
            • Blockchain Transaction
            • Transaction Life Cycle
            • Offchain Operations
            • Light Client
            • Rust for Substrate
            • Introduction to Library
            • Architecture and Rust Libraries
            • File Architecture
            • Accounts, Addresses, and Keys
            • Transaction Format
            • Blockchain Randomness
          • FRAME
            • FRAME Pallets
            • FRAME Macros
            • Custom Pallets
            • Pallet Coupling
            • Origin
            • Events and Erros
            • Runtime Storage
            • State Transitions and Storage
            • SCALE Encoding
            • Weight and Fee
            • Runtime API
            • Runtime Development
          • Account
          • Address Format
          • Glossary
          • CLI
            • Archive
            • Memory Profiler
            • Node Template
            • sidecar
            • srtool
            • Subkey
            • subxt
            • try-runtime
            • tx-wrapper
          • Runtime Development
            • Basics
              • Configure Genesis State
              • Configure Runtime Constants
              • Customize a Chain Spec
              • Import a Pallet
              • Use Helper Function
            • Consensus Model
              • PoW
              • Create a Hybrid Node
            • Offchain Worker
              • Request Offchain HTTP
              • Offchain Indexing
              • Offchain Local Storage
            • Pallet Design
              • Create a Storage Structure
              • Implement Lockable Currency
              • Incorporate Randomness
              • Loose Coupling
              • Tight Coupling
            • Parachain Development
              • Add HRMP Channel
              • Add Paranodes
              • Connect to a Local Relay Chain
              • Convert a Solo Chain
              • Prepare to Launch
              • Select Collator
              • Upgrade a Parachain
            • Storage Migration
              • Basics
              • Trigger Migration
            • Test
              • Basics
              • Test a Transfer Transaction
            • Tools
              • Create a TxWrapper
              • Use Sidecar
              • try-runtime
              • Verify WASM
            • Weigths
              • Benchmark
              • Calculate Fees
              • Use Conditional Weights
              • Use Custom Weights
        • Build
          • Decide What to Build
          • Build Process
          • Determinisitc Runtime
          • Chain Spec
          • Genesis Configuration
          • Application Development
          • RPC
          • Troubleshoot Your Code
        • Tutorials
          • Install
            • Developer Tools
            • Linux
            • macOS
            • Rust Toolchain
            • Issues
            • Windows
          • Quick Start
            • Explore the Code
            • Modify Runtime
            • Start a Node
            • Substrate Basics
          • Build a Blockchain
            • Add Trusted Nodes
            • Authorize Specific Nodes
            • Build a Local Blockchain
            • Simulate Network
            • Upgrade a Running Network
          • Build Application Logic
            • Add a Pallet
            • Add Offchasin Workers
            • Publish Custom Pallets
            • Specify Origin for a Call
            • Use Macros in a Custom Pallet
          • Integrate with Tools
            • Access EVM Accounts
            • EVM Integration
            • Explore Sidecar Endpoints
            • Integrate a Light Client Node
          • Smart Contracts
            • Strategy
            • Build a Token Contract
            • Develop a Smart Contract
            • Prepare Your First Contract
            • Troubleshoot Smart Contracts
            • Use Maps for Storing Values
      • XCM
        • XCM
        • XCM Format
    • Service Chains
      • InfraDID
      • InfraEVM
      • URAuth(Universal Resource Auth)
    • DevOps
      • Build
      • Deploy
      • Monitoring
      • Runtime Upgrade
    • Tutorials
      • Basic
        • How to Interact with System Token
        • How To Pay Transaction Fee
        • How To Vote with TaaV
        • Hot to Get Validator Reward
      • Build
        • Build InfraRelayChain
        • Build Parachain
        • Open Message Passing Channels
        • Transfer Assets with XCM
      • Test
        • Benchmark
        • Check Runtime
        • Debug
        • Simulate Parachains
        • Unit Testing
      • Service Chains
        • Play with InfraDID
          • Build
          • Add Keys
          • Add Service Endpoint
          • Create InfraDID
        • Play with InfraEVM
          • Build
          • Deposit and Withdraw Token
          • Deploy ERC20 Contract
          • Deploy ERC721 Contract
          • Deploy ERC1155 Contract
  • Newnal Data Market
Powered by GitBook
On this page
  • Before you begin
  • Configure XCM instructions
  • WithdrawAsset instruction
  • BuyExecution instruction
  • DepositAsset instruction
  • Submit the transaction
  • Check events on the relay chain
  • Check the assets deposited
  1. InfraBlockchain
  2. Tutorials
  3. Build

Transfer Assets with XCM

This guide shows you how to use XCM to execute remote transfers to parachains via the relay chain.

PreviousOpen Message Passing ChannelsNextTest

Last updated 1 year ago

In , you saw how to open a two-way communication channel between chains by sending messages to the relay chain. You can use a similar strategy to send messages that allow a local chain to manage an account on a remote chain. In this tutorial, parachain B transfers assets into the sovereign account on the relay chain for parachain A.

The outcome for this tutorial is similar to using the transfer function from the balances pallet, except in this case the transfer is initiated by a parachain and demonstrates how the holding register is used when executing the WithdrawAsset and DepositAssetXCM instructions.

Before you begin

Before you begin, verify the following:

  • You have set up a using Zombienet or a local relay chain using the rococo-local chain specification.

  • You have set up two local or virtual parachains for testing purposes.

    For the purposes of this tutorial, parachain A has the unique identifier 1000 and parachain B has the unique identifier 1001.

  • You have the Sudo pallet available for both local parachains to use.

  • You have opened the message passing channel to allow communication between parachain B and parachain A.

Configure XCM instructions

To illustrate the interaction between the two chains, in the following example, parachain B sends XCM instructions to deposit assets into an account on parachain A.

  1. Connect to the endpoint for parachain B (1001) using the .

  2. Click Developer and select Extrinsics.

  3. Select sudo, then select sudo(call) to use the Sudo pallet to execute privileged transactions.

  4. Select ibsXcm, then select send(dest, message).

  5. Specify the destination parameters to indicate the relative location for the message to be delivered.

    • The XCM version for specifying the location of the destination: V1

    • The relay chain is the destination for the message, so the parent location: 1

    • In the context of the parent, the interior setting: Here

  6. Specify the XCM version for the message (V2).

  7. Click Add item to construct the message to be executed.

WithdrawAsset instruction

To move assets into the virtual holding register:

  1. Select WithdrawAsset as the first instruction for this message.

  2. Click Add item to identify the on-chain assets to withdraw.

  3. Select Concrete to use the location of the asset to identify the asset to be withdrawn.

  4. Set parents: 0 and interior: Here to withdraw assets from the parachain B sovereign account on the relay chain.

  5. Select Fungible to identify the asset as a fungible asset.

  6. Specify the total fungible assets to withdraw.

    For example, this tutorial uses 12000000000000.

BuyExecution instruction

To pay for execution from assets deposited in the holding register:

  1. Click Add item to select BuyExecution as the second instruction for this message.

  2. Select Concrete to use the location of the asset to identify the asset to be used to pay for executing XCM instructions.

  3. Set parents: 0 and interior: Here to use the assets withdrawn from the parachain B sovereign account on the relay chain.

  4. Select Fungible to identify the asset as a fungible asset.

  5. Specify the total fungible assets to use.

    For example, this tutorial uses 12000000000000.

  6. Select Unlimited to skip setting a weight limit for this instruction.

DepositAsset instruction

To deposit assets after fees from the holding register into a specific account:

  1. Click Add item to select DepositAsset as the third instruction for this message.

  2. Select Wild to allow an unspecified number of assets to be deposited.

  3. Select All to allow all of the remaining assets after fees are paid to be deposited.

  4. Set 1 as the maximum number of unique assets to remove from the holding register for the deposit.

    In this tutorial, there's only one asset instance available to be removed.

  5. Specify the beneficiary to receive the deposited assets.

    You can deposit the assets remaining into the sovereign account for parachain A or into a specific account. For this tutorial, the assets are deposited using a specified account address for the previously unfunded account KRIS-PUBS. To select this beneficiary, the DepositAsset instruction looks like this:

    If you want to deposit the assets into the sovereign account for parachain A, you could specify the beneficiary using the following settings:

    • parents: 0,

    • interior: X1,

    • X1 junction: Parachain

    • Parachain index: 1000

    After you configure all of the XCM instructions to be executed, you're ready to submit the transaction.

Submit the transaction

To submit the transaction:

  1. Click Submit Transaction.

  2. Click Sign and Submit.

  3. Click Network and select Explorer to verify the message is sent.

    If you expand the event, you can review the message instructions. If you click the link to the block that includes the transaction, you can see additional details

Check events on the relay chain

To check the result on the relay chain:

  1. Click Network and select Explorer to view the events for the XCM message.

  2. Click the block number where the change was recorded to view details.

Check the assets deposited

To verify the assets deposited into the account:

  1. Click Accounts and see the assets minus transaction fees have been deposited into the account.

    For example:

    If you had made the remote transfer to the parachain A (1000) sovereign account instead of the KRIS-PUBS account, you would click Accounts, then select Address book to see the assets withdrawn from the parachain B sovereign account deposited into the parachain A sovereign account.

Open the and connect to the relay chain.

Open the and connect to the relay chain.

Open message passing channels
parachain test network
InfraBlockchain Portal
InfraBlockchain Portal
InfraBlockchain Portal
WithdrawAsset instruction sent from parachain B
BuyExecution instruction sent from parachain B
Specify an account as a beneficiary
Relay Chain events
Assets withdrawn and deposited are recorded on the relay chain
Assets have been deposited in the specified account