Run

This document describes how to run the Second State DevChain.

Binary

The binary executable devchain is the software that runs blockchain nodes.

Single node

First, you need to initialize the configurations and settings on the node computer.

$ devchain node init --home $HOME/.devchain

The genesis.json and config.toml files will be created under the $HOME/.devchain/config directory. You can make changes to those files to customize your blockchain. Then, set env variables for libENI.

$ mkdir -p $HOME/.devchain/eni/lib
$ cd $HOME/.devchain/eni

# Get the lib file. For centos 7 the file name is libeni-1.3.4_centos-7.tgz
$ wget https://github.com/second-state/libeni/releases/download/v1.3.4/libeni-1.3.4_ubuntu-16.04.tgz
$ tar zxvf *.tgz
$ cp libeni-1.3.4/lib/* lib

# For convenience, you should also put these two lines in your .bashrc or .zshrc
export ENI_LIBRARY_PATH=$HOME/.devchain/eni/lib
export LD_LIBRARY_PATH=$HOME/.devchain/eni/lib

Now you can start the node.

Next, in a new terminal window, run the following command to connect to the local DevChain node.

Multiple nodes

First, you need to initialize the configurations and settings on each of the node computer. Run the following command on each machine.

  • Each node has a different $HOME/.devchain/config/priv_validator.json key file. Note down the public key for each of them.

  • On each node, run command devchain node show_node_id –home $HOME/.devchain and note down the seed for each. It is in the format of seed@ip:26656

Next, use this tool to generate a new set of genesis.json and config.toml files for the entire cluster. Enter all the public keys and seeds from the last step into the tool. For example, here is how to create a genesis.json with a custom chain_id, a custom gas_price and public keys from multiple nodes.

Here is how to create a config.toml file with the seeds.

Copy the generated genesis.json and config.toml files back into each node’s $HOME/.devchain/config directory.

Next, set env variables for libENI.

Now you can start each node, and they will form a cluster.

Next, in a new terminal window, run the following command to connect to a local DevChain node in the cluster.

Docker

In the previous section, we have built a Docker image for the node software under the name secondstate/devchain.

Single node

First, you need to initialize the configurations and settings on the node computer.

The genesis.json and config.toml files will be created under the $HOME/.devchain/config directory. You can make changes to those files to customize your blockchain. You may need to sudo su - in order to edit those files since they are created by the root user. The libENI libraries have been built into the docker image so you don’t need to worry about it. Then, you can start the node.

From a second terminal window, you can get the ID of the running Docker container.

Next, log into that container.

Finally, you can attach a console to the node to run web3 commands.

Multiple nodes

First, you need to initialize the configurations and settings on each of the node computer. Run the following command on each machine.

  • Each node has a different $HOME/.devchain/config/priv_validator.json key file. Note down the public key for each of them.

  • On each node, run command devchain node show_node_id –home $HOME/.devchain and note down the seed for each. It is in the format of seed@ip:26656

Next, use this tool to generate a new set of genesis.json and config.toml files for the entire cluster. Enter all the public keys and seeds from the last step into the tool. For example, here is how to create a genesis.json with a custom chain_id, a custom gas_price and public keys from multiple nodes.

Here is how to create a config.toml file with the seeds.

Copy the generated genesis.json and config.toml files back into each node's $HOME/.devchain/config directory.

Now you can start each node, and they will form a cluster.

On a second terminal window on each node, you can get the ID of the running Docker container.

Next, log into that container on a node.

Finally, you can attach a console to the node to run web3 commands.

Last updated

Was this helpful?