Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

How to build HrmpChannel between two parachains? #511

Closed
jonathanxuu opened this issue Jun 25, 2021 · 4 comments
Closed

How to build HrmpChannel between two parachains? #511

jonathanxuu opened this issue Jun 25, 2021 · 4 comments

Comments

@jonathanxuu
Copy link

Want to use xToken to transfer assets between 2 parachains, but don't know how to build HrmpChannel.
I have no idea how to construct request message.

@bkchr
Copy link
Member

bkchr commented Jun 28, 2021

CC @pepyakin

@pepyakin
Copy link
Contributor

pepyakin commented Jun 28, 2021

From a high level, here is the sequence of actions that should take place in order to establish a channel from parachain A to parachain B:

  1. Parachain A calls hrmp_init_open_channel dispatchable with the parachain B as the recipient and the desired parameters of the channel.
  2. Within the next N sessions parachain B calls hrmp_accept_open_channel. sender should be the ID of parachain A.
  3. On the next session change, the channel A→B should be opened.

Note that these dispatchables has the ensure_parachain predicate for the origin. That means that the parachain itself should issue the request. In order to do that, the parachain should send a specially prepared upward message. The simplest way is to use sudo_send_upward_message.

When received, the relay-chain treats an upward message as an XCM. There is an Xcm::Transact, which will execute the given call (aka dispatchable) on the behalf of the parachain. So you need to instantiate the Xcm<C> where C is the Call of the polkadot (or whatever chain you are trying to pull this off on). You would need something like Call::Hrmp(parachains::Call::hrmp_init_open_channel(..)).

This is a bit involved. There were ideas of a dedicated XCM messages just for that. See paritytech/polkadot#3422

@jonathanxuu
Copy link
Author

thanks , it works~

@samelamin
Copy link
Contributor

@jonathanxuu were you able to get it working via the UI?

I cant seem to get the channels open on the UI so I am curious to how you got it working?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants