• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create parallel reality of your Substrate network.

Chopsticks

chopsticks logo

Create parallel reality of your Substrate network.

Quick Start

Fork Acala mainnet: npx @acala-network/chopsticks@latest --endpoint=wss://acala-rpc-2.aca-api.network/ws

It is recommended to use config file. You can check configs for examples.

Run node using config file

# npx @acala-network/chopsticks@latest --config= url | path | config_file_name
# i.e: using configs/acala.yml

npx @acala-network/chopsticks@latest -c acala

Wiki

Documentation and tutorials are available at wiki.

Web testing

Run Chopsticks in browser? Now you can turn a mainnet into a devnet and play with it directly in your browser!

An example is available at acalanetwork.github.io/chopsticks, and the corresponding code can be found in web-test.

Environment Variables

  • PORT: Set port for Chopsticks to listen on, default is 8000
  • LOG_LEVEL: Set log level, default is info. Available options: trace, debug, info, warn, error
  • VERBOSE_LOG: If set, do not truncating log messages

Install

Make sure you have setup Rust environment (>= 1.64).

  • Clone repository with submodules (smoldot)
    • git clone --recurse-submodules https://github.com/AcalaNetwork/chopsticks.git && cd chopsticks
  • Install deps
    • yarn
  • Build wasm. Please do not use IDE's built-in tools to build wasm.
    • yarn build-wasm

Run

  • Replay latest block
    • npx @acala-network/chopsticks@latest run-block --endpoint=wss://acala-rpc-2.aca-api.network/ws
    • This will replay the last block and print out the changed storages
    • Use option -b|--block to replay certain block hash
    • Use option --output-path=<file_path> to print out JSON file
    • Use option --html to generate storage diff preview (add --open to automatically open file)

Dry-run

  • Dry run hep:
npx @acala-network/chopsticks@latest dry-run --help
  • Dry run extrinsic, same as run-block, example:
npx @acala-network/chopsticks@latest dry-run --config=configs/mandala.yml --html --open --extrinsic=0x39028400d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01183abac17ff331f8b65dbeddd27f014dedd892020cfdc6c40b574f6930f8cf391bde95997ae2edc5b1192a4036ea97804956c4b5497175c8d68b630301685889450200000a00008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a480284d717
  • Dry run call, make sure mock-signature-host: true to fake caller's signature:
npx @acala-network/chopsticks@latest dry-run --config=configs/mandala.yml --html --open --extrinsic=0xff00000080969800 --address=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY --at=<block_hash_optional>
  • Dry run a preimage:
npx @acala-network/chopsticks@latest dry-run --endpoint=wss://polkadot-rpc.dwellir.com --preimage=<preimage> --open
  • Dry run a preimage and execute an extrinsic after that:
npx @acala-network/chopsticks@latest dry-run --endpoint=wss://polkadot-rpc.dwellir.com --preimage=<preimage> --extrinsic=<extrinsic> --open
  • Dry run a preimage and execute a call after that, make sure mock-signature-host: true to fake caller's signature:
npx @acala-network/chopsticks@latest dry-run --config=configs/mandala.yml --preimage=<preimage> --extrinsic=<call> --address=<who> --open
  • Run a test node

    • npx @acala-network/chopsticks@latest --endpoint=wss://acala-rpc-2.aca-api.network/ws
    • You have a test node running at ws://localhost:8000
    • You can use Polkadot.js Apps to connect to this node
    • Submit any transaction to produce a new block in the in parallel reality
    • (Optional) Pre-define/override storage using option -s|--import-storage=storage.[json/yaml]. See example storage below.
    {
      "Sudo": {
        "Key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
      },
      "TechnicalCommittee": {
        "Members": ["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"]
      },
      "Tokens": {
        "Accounts": [
          [
            ["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", { "token": "KAR" }],
            {
              "free": 1000000000000000,
            }
          ]
        ]
      },
      "Whitelist": {
        "WhitelistedCall": [
          [
            ["0x3146d2141cdb95de80488d6cecbb5d7577dd59069efc366cb1be7fe64f02e62c"],
            "0x" // please use 0x for null values
          ],
        ]
      }
    }
  • Run Kusama fork

    • Edit configs/kusama.yml if needed. (e.g. update the block number)
    • npx @acala-network/chopsticks@latest --config=configs/kusama.yml
  • Setup XCM multichain NOTE: You can also connect multiple parachains without a relaychain

npx @acala-network/chopsticks@latest xcm -r kusama -p karura -p statemine

Proxy

Chopsticks respect http_proxy and https_proxy environment variables. Export ROARR_LOG=true environment variable to enable log printing to stdout. To learn more, see https://www.npmjs.com/package/global-agent?activeTab=readme

Plugins

Chopsticks is designed to be extensible. You can write your own plugin to extend Chopsticks' functionality.

There are 2 types of plugins: cli and rpc. cli plugins are used to extend Chopsticks' CLI, while rpc plugins are used to extend Chopsticks' RPC.

To create a new plugin, you could check out the run-block plugin as an example.

More Repositories

1

Acala

Acala - cross-chain DeFi hub and stablecoin based on Substrate for Polkadot and Kusama.
Rust
741
star
2

acala-evm-dev-docs

269
star
3

Acala-white-paper

Acala Network whitepapers
99
star
4

subway

Rust
68
star
5

acala.js

TypeScript
59
star
6

bodhi.js

TypeScript
32
star
7

acala-wiki

Acala GitBook Wiki, https://wiki.acala.network
24
star
8

e2e-tests

TypeScript
20
star
9

predeploy-contracts

Solidity
19
star
10

acala-subql

TypeScript
10
star
11

Acala-Grants-Program

Acala Foundation Grants Program
9
star
12

hardhat-tutorials

TypeScript
9
star
13

acala-js-example

TypeScript
8
star
14

evm-examples

TypeScript
8
star
15

parachain-utilities

A set of tools to improve the life quality of parachain developers.
TypeScript
7
star
16

evm-provider

TypeScript
4
star
17

polkawallet_plugin_karura

Karura network plugin for Polkawallet.
Dart
4
star
18

polakdot-hello-world-acala

Gitcoin Polkadot Hello World Hackathon.
3
star
19

collateral-auction-bot-example

TypeScript
3
star
20

ecosystem-template

Rust
3
star
21

e2e

TypeScript
3
star
22

AcalaBounties

3
star
23

token-resources

resources include token and network
JavaScript
3
star
24

scripts

TypeScript
3
star
25

evm-playground

TypeScript
3
star
26

Euphrates

Solidity
3
star
27

txwrapper

TypeScript
2
star
28

truffle-tutorials

JavaScript
2
star
29

acala-utils

TypeScript
2
star
30

wormhole-relayer

TypeScript
2
star
31

evm-dapp-collection

Good place to submit information of Acala EVM Dapps.
2
star
32

issue-collection

Good place to submit BUGs.
2
star
33

cdp-bot-template

Template for deploying on Heroku using the "Deploy on Heroku" button
JavaScript
2
star
34

karura-whitepaper

2
star
35

auction-bot

TypeScript
2
star
36

karura-dashboard

1
star
37

polka-defi-website

TypeScript
1
star
38

acala-homa-subql

JavaScript
1
star
39

product-feedback

1
star
40

translation

1
star
41

acala-loan-subql

JavaScript
1
star
42

acala-evm-indexer-examples

TypeScript
1
star
43

acala-trace

TypeScript
1
star
44

karura-website

JavaScript
1
star
45

acala-evm-tests

TypeScript
1
star
46

bodhi-examples

some examples to use bodhi sdk
TypeScript
1
star
47

acala-subql-services

TypeScript
1
star
48

karura-testnet

Dockerfile
1
star
49

evm-tests

Rust
1
star
50

lucky-running-nodes

JavaScript
1
star
51

acala-test-utils

some utils for test acala network
HTML
1
star
52

guardian-bot-heroku-template

Template for deploying on Heroku using the "Deploy on Heroku" button
JavaScript
1
star
53

waffle-tutorials

TypeScript
1
star