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.
$devchainnodeinit--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$wgethttps://github.com/second-state/libeni/releases/download/v1.3.4/libeni-1.3.4_ubuntu-16.04.tgz$tarzxvf*.tgz$cplibeni-1.3.4/lib/*lib# For convenience, you should also put these two lines in your .bashrc or .zshrcexport ENI_LIBRARY_PATH=$HOME/.devchain/eni/libexport LD_LIBRARY_PATH=$HOME/.devchain/eni/lib
Now you can start the node.
$devchainnodestart--home $HOME/.devchain
Next, in a new terminal window, run the following command to connect to the local DevChain node.
First, you need to initialize the configurations and settings on each of the node computer. Run the following command on each machine.
$devchainnodeinit--home $HOME/.devchain
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.
Copy the generated genesis.json and config.toml files back into each node’s $HOME/.devchain/config directory.
Next, 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$wgethttps://github.com/second-state/libeni/releases/download/v1.3.4/libeni-1.3.4_ubuntu-16.04.tgz$tarzxvf*.tgz$cplibeni-1.3.4/lib/*lib# For convenience, you should also put these two lines in your .bashrc or .zshrcexport ENI_LIBRARY_PATH=$HOME/.devchain/eni/libexport LD_LIBRARY_PATH=$HOME/.devchain/eni/lib
Now you can start each node, and they will form a cluster.
$devchainnodestart--home $HOME/.devchain
Next, in a new terminal window, run the following command to connect to a local DevChain node in the cluster.
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.
$dockercontainerlsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0bcd9da5bf05 secondstate/devchain "./devchain node sta…" 4 minutes ago Up 4 minutes 0.0.0.0:8545->8545/tcp, 0.0.0.0:26657->26657/tcp, 26656/tcp pedantic_mendeleev
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.
On a second terminal window on each node, you can get the ID of the running Docker container.
$dockercontainerlsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0bcd9da5bf05 secondstate/devchain "./devchain node sta…" 4 minutes ago Up 4 minutes 0.0.0.0:8545->8545/tcp, 0.0.0.0:26657->26657/tcp, 26656/tcp pedantic_mendeleev