Skip to main content

PolkadotXcm

The XCM (Cross-Chain Message), is a communication protocol enabling parachains within the Polkadot network to interact with each other. This includes the ability for parachains to exchange messages, perform token transfers, and invoke functions on other parachains.

Functionality

To use XCM communication protocol, it is necessary to first create an HRMP channel between two parachains. For the demonstration purposes we will use the parachain-launch project, and configure the HRMP channel there. Since the HRMP channel is unidirectional, two channels need to be created to facilitate bidirectional communication.

From parachain with ID 200 to parachain with ID 300

xcm-1 From parachain with ID 300 to parachain with ID 200

xcm-2

Enable the capability to send Rococo's tokens from the relay chain.

When transferring the relay chain's token to a parachain, the xToken-related extrinsic cannot be utilized. Instead, we must use the xcmPallet.reserveTransferAssets function, which allows for the transfer of assets from the local chain to the sovereign account of the destination chain and forwards a notification XCM.

xcm-3

Internal Logic on the Relay Chain

  1. Send DOT Tokens to the Sovereign Account The relay chain calculates the sovereign account for the parachain. As a result, the sovereign account won't have the private key to secure the assets.

  2. Use DOT to Pay the Weight Fee from the Sending Account

Internal Logic on the Parachain

  1. Subtract DOT Tokens as Weight The parachain subtracts the DOT tokens as weight, based on the weight fee for the transaction.

  2. Deposit the DOT Tokens to the Destination

The platform offers support for sending Rococo's tokens to the relay chain.

When the need arises to transfer tokens from a parachain, we can utilize the xTokens pallet. This pallet facilitates users to send an extrinsic that encompasses multiple XCM commands in a single transaction.

xcm-4

Internal Logic on the Parachain

  1. Burn the DOT tokens in the sender's account.
  2. Spend PEAQ tokens as the weight fee from the sending account.

Internal Logic on the Relay Chain

  1. Subtract the DOT token as a fee.
  2. Spend the DOT token as the fee from the deposit tokens.

The system provides support for receiving Acala's token from Parachain ID 3000.

The process of sending the Relay chain's token to the parachain is similar, with the key distinctions being the multilocation and the specific token involved.

xcm-5

Acala chain

  1. Send ACA to the sovereign account.
  2. Use ACA to pay the fee from the sending account.

peaq chain

  1. Subtract the ACA tokens as Weight.
  2. Deposit the ACA token to the destination.

Support sending the peaq Token to parachain ID 3000.

  1. Register the foreign account in Acala

It's essential that we have to register the PEAQ token in Acala's chain. Otherwise, Acala's chain didn't know to interpret the PEAQ token.

xcm-6

peaq parachain

  1. Send PEAQ to the sovereign account

xcm-7

  1. Use PEAQ to pay the fee from the sending account

Acala parachain

  1. Deposit the PEAQ token to the destination