subquery / subql-examples

Apache License 2.0
11 stars 8 forks source link

Example for Cross-chain Message Passing #10

Open ianhe8x opened 3 years ago

ianhe8x commented 3 years ago

Once X-Token is enabled in Rococo, user will allow to transfer tokens between parachain and relay chain. We can create a example to track the asset flow.

Furthermore, XCMP comes with its own events, life cycle of messages between chains is a quite interesting topic we can discuss here.

ianhe8x commented 3 years ago

A Detailed Example for cross chain transfer initiator Plasm, parachainId 5000 receiver Acala, parachainId 666

1) send

Plasm sent a x-token transfer at height 10003 (https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.rococo.plasmnet.io#/explorer/query/0xbf0beede832b68c3548d8eee1e99ef1bfbf6d2bcaf5117b315559276bee52e79) relayParentNumber: 79,474

2) receive

Acala received and processed the message at Height 8004 (https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-1.acala.laminar.one%2Fws#/explorer/query/0x3aaa97d149441b94e044e1fb58fbb2caf353170cbd16ff8b7bdd7d0e4303d25b) relayParentNumber: 79,476

3) evidence from Rococo

  1. await api.query.hrmp.hrmpChannelDigests.at(await api.rpc.chain.getBlockHash(79476),666) can see a message from parachain 5000
  2. await api.query.hrmp.hrmpChannelContents.at(await api.rpc.chain.getBlockHash(79476),{sender: 5000, receiver:666}) can retrieve message data, we should be able to compare it with the hash from Plasm @79474 event xcmHandler.HrmpMessageSent