Managing Multiple Networks

Switching between Networks

All accounts managed by ft are associated with a given network, also called switches.

The sub-command to switch between networks is ft switch:

$ ft switch list
Loading wallet file /home/lefessan/.ft/mainnet/wallet.json
* testnet
  - tonlabs (current if network was selected)
    url: https://net.ton.dev
* mainnet (current)
  - tonlabs (current)
    url: https://main.ton.dev
* rustnet
  - tonlabs (current if network was selected)
    url: https://rustnet.ton.dev
* fldnet
  - tonlabs (current if network was selected)
    url: https://fld.ton.dev
* sandbox1
  - node (current if network was selected)
    url: http://0.0.0.0:7081

Here, the output tells us that ft knows about 5 networks, 4 of whom are public ones from the default configuration (testnet, mainnet, rustnet and fldnet) and one is a local one called sandbox1.

The output also tells us that mainnet is currently selected (so that all commands apply to this network by default), and that it uses the (predefined) node called tonlabs at URL https://main.ton.dev.

It is then possible to switch to a different network with:

$ ft switch to testnet
Switched to network "testnet"

Now, all commands would apply to the testnet network by default.

It is possible to specify the network to which a particular command applies using the early --switch argument:

$ ft --switch NETWORK SUBCOMMAND [ARGUMENTS]

or the FT_SWITCH environment/shell variable:

$ FT_SWITCH=testnet ft SUBCOMMAND [ARGUMENTS]

Creating and Removing Public Networks

It is possible to create a new network using:

$ ft switch create fabnet --url https://fab.ton.dev

This will create a new public network called fabnet, with a node called node with the URL https://fab.ton.dev. This network is immediately promoted as the default network.

It is possible to remove an existing network using:

$ ft switch remove fabnet

However, this command will fail if the network is the current one, so you must switch to another network before using it.

Beware that removing a network removes all the keys associated with it.

Creating Sandbox Networks

When creating new networks, ft behaves differently when networks start with sandbox. The name should be sandboxNUM where NUM is a small number.

In this case, ft will create a local docker network using tonlabs/local-node image, on local port 7800+NUM.

It will also create a remote account giver corresponding to the contracts holding the tokens on the local network, and 10 local Surf accounts, called user0 to user9. All these accounts always have the same public and secret keys and raw addresses on all sandbox networks, to ease debugging when restarting the networks.

Creating the network will not start the node. Instead, you must call:

$ ft node start

to start the network.

To stop it, you must use:

$ ft node stop

If you want to query its Graphql playground interface, you may use:

$ ft node web

Finally, you may want to give tokens to local accounts (such as user0, etc.).

For that, you may use:

$ ft node give

By default, this command will give 1000 TON to every local account with a balance smaller than this amount, and try to deploy a Surf smart contract if the account is not initialized.

You may also specify a given account, and a minimal balance in TON:

$ ft node give user0 --amount 100000