Why support multi-chain?

In the chain network system, there will be various, large and small application chains, vertical industry chains, and the development environment supports the launch of multiple chains, which is very convenient for developers when testing cross-chain characteristics.

Forge CLI multi-chain support is available at v0.35.0 Added in version.

Storage rules for multi-chain data

Forge CLI's multi-chain support is implemented based on the file system. Each node of the chain has its own configuration and data storage directory. The information storage locations are as follows:

Finding rules when multi-chain

When there are multiple chains, when the Forge CLI receives a certain instruction, it will see if the user has specified a certain chain. If not, it will search according to the following rules:

  1. Finding currently running chains
  2. If there are running chains, arrange the running chain names in ascending alphabetical order, and take the first as the default chain
  3. If there are no running chains, the names of all chains are listed in ascending alphabetical order, and the first one is taken as the default connection.

Not all Forge CLI self-commands need to specify chain parameters, such as forge install with forge download No need.

Specify a chain name for the command

The basic syntax of multi-chain operation is as follows:

-c Or --chain-name It is a parameter of the custom chain supported by most Forge CLI subcommands. In the case of only one chain, this parameter can be completely ignored.

Create new chain

Start a chain

Stop a chain

Read and write data on the chain

Upgrade a chain

Contract management

Start and stop various tools

forge web start | stop [--chain-name | -c <chain name>]

The syntax applies to: simulator, workshop, swap