How to run a single node test network
It can be very useful to be able to run a single node network for testing purposes when undergoing contract development. This document outlines the steps required in order to configure a
fetchd network of 1 node (i.e. single node network).
These steps only need to be carried out once to setup the local network correctly.
Build the ledger from source: follow the installation ↗️ instructions in order to compile the latest version of the Ledger.
Remove any existing networks: since we are starting a new network, we need to remove any local files that we have in our system from a previous network. You can do so by running:
rm -Rf ~/.fetchd
Create an initial genesis: let's now create the initial genesis file (
~/.fetchd/config/genesis.json) with the following command:
fetchd init --chain-id localnet-1 my-local-node-nameℹ️
localnet-1is the chain id
my-local-node-nameis the moniker for the node
If you want to make any updates to the genesis, it is a good time to make these updates now.
Create a validator key: let's now create a validator key which will be used as the public/private keypair for our node. Let's create a new key called
validatorusing the following command:
fetchd keys add validatorℹ️
validatoris the name of the key in the keyring.
For more information, checkout the complete keys ↗️ documentation.
Add the validator to the network: let's now set the initial state for the network, allocating
staketokens to the validator which can be bonded. This is performed with the following command:
fetchd add-genesis-account validator 100000000000000000000stakeℹ️
stakeis the default test token denomination in the cosmos ecosystem, but you could use
BTC, and so on.
Generate a transaction: now, let's generate a validator transaction. You can get your validator to sign the genesis block, and to agree that this is the correct genesis starting point, using the following command:
fetchd gentx validator 100000000000000000000stake --chain-id localnet-1ℹ️
validatoris the name that you have given to the key.
Build final genesis configuration: finally, we would need to build the complete and final genesis configuration for the network by running the following command:
After running this command, the network will be successfully configured and you have computed the final genesis configuration for the network.
Let's now run the network. We need to use the following command:
It may happen that you may want to clear out all the data from the network and start it again. You can do this in a local network, by simply running the following command:
fetchd tendermint unsafe-reset-all
This will reset the chain back to genesis configuration.
You DO NOT need to perform the network setup steps again. After running this command, you can simply run the
fetchd start command again.