Mideg Dugarova
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    1
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # HRMP channel opening The goal of this tutorial is to show and explain how parachains can open their bidirectional channels with Statemine on Kusama network. ## Part 1. Opening the channel from Statemine to your parachain. Key points: - Each chain needs to send or accept incoming requests to open a channel with their parachain origin. Because Statemine is a common goods parachain, its root origin is controlled by the Kusama Relay Chain governance. - In this part we will construct an XCM message with necessary instructions to open a channel from Statemine to your parachain and encode it to pass as a motion through democracy. ### Steps: 1. Create an extrinsic to request a channel opening from Statemine to your parachain. Go to Extrinsics page in Developer tab. Select **hrmp.initOpenChannel** extrinsic and fill parameters: * *recipient* field should contain your paraid, * *proposedMaxCapacity* is the maximum number of messages that can be pending in the channel at once * *proposedmaxMessageSize* is the maximum total size of the messages that can be pending in the channel at once. ![](https://i.imgur.com/kptbNnc.png) 2. This extrinsic should be submitted by Statemine, therefore we do not submit the transaction. Instead we copy the *encoded call data* to further include in the Transact Instruction within the XCM message. 3. Now we need to create an XCM message to be sent to the Relay Chain (from Statemine). We construct the message on Statemine (!). Go to Developer -> Extrinsics -> **polkadotXcm.send(dest, message)** * As of writing of this tutorial the version of multilocation is V1 * Fill field parents with 1 and interior with Here. * Choose V2 for message ![](https://i.imgur.com/g9YJ8CU.png) 4. Our XCM message will consist of some XCM Instructions we want the Relay chain to execute. * *WithdrawAsset*. This instruction enables available funds to be used for various purposes in the future. We will use these funds in the next Instruction to pay fees for the execution of our XCM message. This is in the context of its execution, which is on the Relay Chain, so parents should be 0 and the location is Here. This particular XCM message uses 0.000107 KSM, but it is possible to withdraw more funds to be sure in field *Fungible*. ![](https://i.imgur.com/uY6M6F7.png) * *BuyExecution*. This instruction pays execution fees. ![](https://i.imgur.com/YuAC89M.png) * *Transact*. This instruction contains necessary calls that are to be executed by the recipient of the message - in this case, by the Relay Chain. The Native type will take on the origin of the parachain, in this case Statemine. The encoded call should be the call constructed above in step 1. These are the instructions we want to execute on behalf of the parachain. ![](https://i.imgur.com/6lUcpMK.png) * *RefundSurplus* instruction, which refunds any unused weight from execution. * *DepositAsset* instruction, which instructs the executor to deposit any KSM that wasn't used on transaction fees back into the Kusama Treasury. So rather than a bit extra being left over, it uses exactly what it needs and returns the rest. 5. Because this message can only be executed with the chain’s root - in this case this is Kusama governance, we cannot submit this extrinsic. We need to copy the encoded data call again and make a motion to the governance for the Kusama Relay Chain to send this message to Statemine. Go to Democracy module on Kusama (governance -> democracy) and submit the preimage. 6. Statemine is a common goods parachain and therefore it doesn’t have necessary balances to pay for the channel opening and the deposit. Apart from executing our XCM message, we would need to propose to forcetransfer some funds from Kusama treasury to Statemine. This is why we propose batch of calls - **utility.batchAll(calls)**. 7. At this time (Kusama v9130), the deposit is 5 KSM per one-way channel (i.e. a bi-directional channel would require 10 KSM). Make sure to *force_transfer* a little more for the *WithdrawAsset*. It is more than enough to add 0.1 for fees. > Kusama Treasury Account: F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg2 > Statemine Account: F7fq1jSNVTPfJmaHaXCMtatT1EZefCUsa7rRiQVNR5efcah 8. Second call in the batch is **xcmPallet.send(dest, message)**. Because the call is executed on the Relay Chain, we are sending a Transact message that contains our encoded call to Statemine. 9. After the proposal is submitted the destiny of the channel opening will be decided by democracy. If approved, one thing left is to accept the incoming request on your chain. For this you only need to submit a regular extrinsic on chain **hrmp.hrmpAcceptOpenChannel(sender)** and pass the Statemine’s ParaId (1000) as a parameter. The channel is open! ## Part 2. Opening the channel from your parachaini to Statemine. Here we follow the reverse procedure - first we submit a transaction that requests channel opening with Statemine and then have Statemine accept it via governance. ### Steps: 1. First we construct and submit an extrinsic that requests channel opening with Statemine. Go to Developers -> Extrinsics, select **hrmp.initOpenChannel** like previously. The recipient field should contain Statemine’s paraid (1000). Unlike in part 1 we need to submit this transaction onchain to execute. 2. Now we follow a similar procedure that we used in part one. * Construct extrinsic that accepts the request to open a channel with your ParaId as a parameter. Copy the encoded data call. * Construct an XCM message with *WithdrawAssets*, *BuyExecution* and *Transact* Instructions. * Create a proposal with a batch of calls (**balances.ForceTransfer** and **xcmPallet.send()**) and submit it. * Wait for the governance to approve the proposal.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully