Skip to content

How to Use Chopsticks to Fork Your Appchain


Chopsticks provides a developer-friendly method of locally forking existing Substrate-based chains. It allows for the replaying of blocks to easily examine how transactions affect the state, the forking of multiple Appchains for XCM testing, and more. This empowers developers to test and experiment with their custom blockchain configurations in a local development environment without deploying a live network.

Overall, Chopsticks aims to simplify the process of building blockchain applications on Substrate and make it accessible to a wider range of developers.

This article will cover using Chopsticks to fork and interact with the local copy of a Tanssi ContainerChain.


Chopsticks currently does not support calls done via the Ethereum JSON-RPC. Consequently, you can't fork your chain using Chopsticks and connect Metamask to it.


The original Chopsticks project supports the Babe and Aura block production algorithms. However, to ensure compatibility with the Tanssi block production as a service protocol, modifications have been made and published in a new fork of the original repository.

To follow along with this tutorial, you will need to clone the repository along with its submodules(Smoldot):

git clone --recurse-submodules

Then, get into the folder and install the dependencies using yarn:

 cd chopsticks && yarn

Finally, build the project:

yarn build-wasm

Now the development environment is ready to start testing and debugging Tanssi-deployed ContainerChains.

Forking a Demo EVM ContainerChain with Chopsticks

To fork an Appchain using Chopsticks, execute the command with only the RPC endpoint as a parameter:

yarn start --endpoint wss://

This command will start a local clone of the chain as it was in the latest block.

chopsticks % yarn start --endpoint wss:// [01:59:42.628] INFO (xcm/59650): Frontier Container 3001 RPC listening on port 8000

Typically, the configuration parameters are stored in a configuration file, as are the configurations in the repository's configs folder for the relay chains and parachains deployed in the Dotsama ecosystem. The following configuration file works for the Demo EVM ContainerChain, overriding the chain's sudo account with Alith's and additionally funding the account with tokens:

endpoint: wss://
mock-signature-host: true
allow-unresolved-imports: true
db: ./tmp/db_ftrcon.sqlite

      - - - "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" # Alith
        - providers: 1
          sufficients: 1
          consumers: 1
            free: "100000000000000000000000"
    Key: "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"

The configuration file accepts all of the following parameters:

Option Description
genesis The link to a parachain's raw genesis file to build the fork from, instead of an endpoint.
timestamp Timestamp of the block to fork from.
endpoint The endpoint of the parachain to fork.
block Use to specify at which block hash or number to replay the fork.
wasm-override Path of the WASM to use as the parachain runtime instead of an endpoint's runtime.
db Path to the name of the file that stores or will store the parachain's database.
config Path or URL of the config file.
port The port to expose an endpoint on.
build-block-mode How blocks should be built in the fork: batch, manual, instant.
import-storage A pre-defined JSON/YAML storage file path to override in the parachain's storage.
allow-unresolved-imports Whether to allow WASM unresolved imports when using a WASM to build the parachain.
html Include to generate storage diff preview between blocks.
mock-signature-host Mock signature host so that any signature starts with 0xdeadbeef and filled by 0xcd is considered valid.

You can run the command yarn start to fork chains by specifying a local configuration file. Alternatively, the name or the GitHub URL can be used if the chain is listed in the repository's configs folder.

yarn start --config=configs/polkadot.yml
yarn start --config=polkadot
yarn start \

All settings (except genesis and timestamp) can also be passed as flags to configure the environment completely in the command line. For example, the following command forks the demo EVM ContainerChain at block 100.

yarn start --endpoint wss:// --block 100

Interacting with a Fork

When running a fork, by default, it will be accessible at:


You can interact with the parachain via libraries such as Polkadot.js and its user interface, Polkadot.js Apps.

Polkadot Js

You should now be able to interact with the forked chain as you would with the real one.


If your browser cannot connect to the WebSocket endpoint provided by Chopsticks, you might need to allow insecure connections for the Polkadot.js Apps URL. Another solution is to run the Docker version of Polkadot.js Apps.

Replaying Blocks

If you would like to replay a block and retrieve its information to dissect the effects of an extrinsic, you can use the yarn start run-block command. Its following flags are:

Flag Description
endpoint The endpoint of the parachain to fork.
block Use to specify at which block hash or number to replay the fork.
wasm-override Path of the WASM to use as the parachain runtime instead of an endpoint's runtime.
db Path to the name of the file that stores or will store the parachain's database.
config Path or URL of the config file.
output-path=/[file_path] Use to print out results to a JSON file instead of printing it out in the console.
html Include to generate an HTML representation of the storage diff preview between blocks.
open Whether to open the HTML representation.

For example, running the following command will re-run the demo EVM ContainerChains's block 1000 and write the storage diff and other data in a chain-output.json file:

yarn start run-block  \
--endpoint wss://  \
--output-path=./chain-output.json  \
--block 1000

WebSocket Commands

Chopstick's internal WebSocket server has special endpoints that allow the manipulation of the local Substrate chain.

These are the methods that can be invoked and their parameters:

Method Parameters Description
dev_newBlock options Generates one or more new blocks.
dev_setStorage values, blockHash Create or overwrite the value of any storage.
dev_timeTravel date Sets the timestamp of the block to the date value.
dev_setHead hashOrNumber Sets the head of the blockchain to a specific hash or number.
Parameters details
Parameter Format Example
options { "to": number, "count": number } { "count": 5 }
values Object { "Sudo": { "Key": "0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b" } }
blockHash string "0x1a34506b33e918a0106b100db027425a83681e2332fe311ee99d6156d2a91697"
date Date "2030-08-15T00:00:00"
hashOrNumber number | string
  • options { "to": number, "count": number } - a JSON object where "to" will create blocks up to a certain value, and "count" will increase by a certain number of blocks. Use only one entry at a time within the JSON object
  • values Object - a JSON object resembling the path to a storage value, similar to what you would retrieve via Polkadot.js
  • blockHash string - optional, the block hash at which the storage value is changed
  • date Date - a Date string (compatible with the JavaScript Date library) that will change the timestamp at which the next blocks being created will be. All future blocks will be sequentially created after that point in time
  • hashOrNumber number | string - if found, the chain head will be set to the block with the block number or block hash of this value

Each method can be invoked by connecting to the WebSocket (ws://localhost:8000 by default) and sending the data and parameters in the following format. Replace METHOD_NAME with the method's name, and replace or delete PARAMETER_1 and PARAMETER_2 with the parameter data relevant to the method:

    "jsonrpc": "2.0",
    "id": 1,
    "method": "METHOD_NAME",
    "params": ["PARAMETER_1", "PARAMETER_2", "..."]
The information presented herein has been provided by third parties and is made available solely for general information purposes. Tanssi does not endorse any project listed and described on the Tanssi Doc Website ( Tanssi Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Tanssi Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Tanssi Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Tanssi Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Tanssi Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
Last update: January 24, 2024
| Created: January 23, 2024