Xiliang Chen
    • 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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Governance fun with Chopsticks How to use Chopsticks to have a mainnet fork of Polkadot/Kusama locally for OpenGov experiments. The developer docs can be found at https://acalanetwork.github.io/chopsticks/docs/ ## Requirements - Basic understanding of how to use command line tools - Know how to encode and decode extrinsics ## Prerequisites - Install nodejs https://nodejs.org/en ## Run Chopsticks ### Single Network `npx @acala-network/chopsticks@latest --config kusama` List of available networks can be found here: https://github.com/AcalaNetwork/chopsticks/tree/master/configs You may submit a PR to add new networks (or ask a dev to do it if you don't know how to submit a PR) ### Multiple Networks `npx @acala-network/chopsticks@latest xcm --relaychain kusama --parachain karura` Multiple `--parachain CHAIN_NAME` can be specified. Check the log output for the port of each chain ## Access the network The Chopsticks RPC url will be `ws://127.0.0.1:8000` or with port 800X for additional instances. You may use any tools to connect to this endpoint and start using it. The easiest way is use pjs apps https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8000#/explorer Note: if it isn't loading, make sure you have configured your browser to support insecure localhost. You may start using pjs apps to send transactions and browse the network. By default, the network will produce new block only when received a transaction. ## Dev RPCs Chopsticks offers multiple dev RPCs to modify the devnet ### dev_newBlock This can be used to build new blocks. Docs: https://acalanetwork.github.io/chopsticks/docs/chopsticks/README.html#newblock ### dev_setHead This can be used to revert block, in case you want to undo something, you can do `await api.rpc('dev_setHead', -1)`. Docs: https://acalanetwork.github.io/chopsticks/docs/chopsticks/README.html#sethead ### dev_setStorage This can be used to modify storage. Docs: https://acalanetwork.github.io/chopsticks/docs/chopsticks/README.html#setstorage ```ts api.rpc('dev_setStorage', { system: { account: [[['FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP'], { providers: 1, data: { free: '10000000000000'}}]] } }) ``` Run the above code in https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8000#/js with Kusama will set the balance of `Bob` to 10 KSM. ## Dispatch Call For the networks that have sudo pallet, we can simply use `dev_setStorage` to set the sudo key to Alice and use sudo to dispatch calls. However, most of the networks does not have sudo pallet, including Kusama and Polkadot. In this case, we can use scheduler pallet to dispatch the call. This is an example of using root to perform force transfer. Note: it can take up to a few minutes for the block to be produced. ```ts const number = (await api.rpc.chain.getHeader()).number.toNumber() await api.rpc('dev_setStorage', { scheduler: { agenda: [ [ [number + 1], [ { call: { Inline: '0x040200d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48070010a5d4e8' }, origin: { system: 'Root' } } ] ] ] } }) await api.rpc('dev_newBlock') ``` Note that we can specify the dispatch origin. This means we can simulate the outcome of a call when dispatched by a particular OpenGov tracks. For example, this simulates to spend 100 KSM from SmallTipper track ```ts const number = (await api.rpc.chain.getHeader()).number.toNumber() await api.rpc('dev_setStorage', { scheduler: { agenda: [ [ [number + 1], [ { call: { Inline: '0x12030b00407a10f35a008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48' }, origin: { origins: 'SmallTipper' } } ] ] ] } }) await api.rpc('dev_newBlock') ``` and it will fail with `treasury.InsufficientPermission` error indicate `SmallTipper` cannot spend 100 KSM. ## Propose Bounty A bounty have multiple phases: Proposed, Approved, Funded, CuratorProposed, Active, PendingPayout. (Code: https://github.com/paritytech/polkadot-sdk/blob/048a9c2744ca83ef6faeadd2cd19466295d52b9d/substrate/frame/bounties/src/lib.rs#L147-L175) It is only possible to propose a curator after the bounty is approved and fund and treasury only fund bounty and other spending proposals every funding period (6 days in Kusama and 24 days in Polkadot). This means it is not possible to have a single referendum to approve a bounty and propose a curator. Except with Treasurer origin, which have access to scheduler.schedule call. The original intention is to allow treasurer origin to schedule reoccurring payouts, but in this case, can also be used to schdule propose curator after the bounty is funded. To try it out: ```ts const number = (await api.rpc.chain.getHeader()).number.toNumber() await api.rpc('dev_setStorage', { scheduler: { agenda: [ [ [number + 1], [ { call: { Inline: '0x1802082301641d00815c400100fe230264008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48070010a5d4e8' }, origin: { origins: 'Treasurer' } } ] ] ] } }) await api.rpc('dev_newBlock') ``` This will dispatch a proposal using Treasurer origin to approve bounty 25, and schedule propose curator at blcok 20995201, the block after the current funding period ends. The schduled call can be found at https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8000#/scheduler Then we can do a time warp with `await api.rpc('dev_newBlock', { count: 2, unsafeBlockHeight: 20995200 })` to directly build block 20995200 and 20995201. Note this is unsafe as it skips all the block between current block and 20995200. But we shall see the bounty status for bounty 25 is CuratorProposed now.

    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