How to Launch a Cosmos SDK BlockChain with a Single Validator Node

How to Launch a Cosmos SDK BlockChain with a Single Validator Node

This guide provides a step-by-step process to set up and launch a node for a Cosmos SDK-based blockchain. For this example we will clone Juno and launch it as an independant chain with one validator node, but you can use your own Cosmos SDK chain, as the process is similar. The instructions below assume you are using a cloud service provioder like Digital Ocean.

SSH into Digital Ocean

ssh root@your.node.ip.address

Install Dependencies

Update the package list and install the necessary build tools and utilities:

sudo apt update -y
sudo apt install build-essential gcc git wget curl -y

Configure Environment Variables

Set up the necessary environment variables by editing the .bashrc file:

cd $HOME
nano ~/.bashrc

Add the following lines

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export PATH=$PATH:~/go/bin

Save the file and reload it:

source ~/.bashrc

For certain Linux distributions or macOS, you may need to adjust the profile file used (e.g., .zshrc or .bash_profile). You can determine the active profile with:

echo $PROFILE
#or search for it with:
ls -a 

Install Golang

As of writing Juno requires Go version 1.22.2 or higher. This tutorial uses version 1.22.2:

FYI - Juno tends to automatically install this depedancy with make install command below. So this may not be necessary. Note: You should use the version of golang that you used to create your chain with.

sudo wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz

Verify the installation by checking the Go version:

go version

If there is an error, it may indicate that Go was not correctly added to your system’s PATH.

Clone the GitHub Repository

git clone https://github.com/CosmosContracts/juno.git

Install the Chain Binary

cd juno 

make install 

Initialize a Node

Next, initialize the node with a moniker (nickname):

junod init myvalnode --chain-id juno

This command creates the necessary configuration files in a hidden folder called .juno (most likely located in your $HOME directory.

Edit Configuration Files

You need to make a few adjustments to the configuration files to properly configure the node:

Set the minimum gas price.

Enable both the REST API and Swagger generation.
Change the RPC setting to allow external access.
Run the following commands to make these changes:

sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "0juno"/' ~/.juno/config/app.toml
sed -i '/\[api\]/,+3 s/enable = false/enable = true/' ~/.juno/config/app.toml
sed -i '/\[api\]/,+6 s/swagger = false/swagger = true/' ~/.juno/config/app.toml
sed -i 's/laddr = "tcp:\/\/127\.0\.0\.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/' ~/.juno/config/config.toml

Create Account Keys

Create a new set of keys for your account:

junod keys add elon

This command will generate a mnemonic phrase and set up your account keys.

Create Genesis Account

Add your account to the genesis block with a starting balance:

junod add-genesis-account elon 1000000000juno

This will endit the genesis.json file.

Upgrade the Node to a Validator

Submit a genesis transaction to upgrade your node to a validator:

junod gentx elon 700000000juno --keyring-backend=os --chain-id=juno \
    --moniker=myvalnode \
    --commission-max-change-rate=0.01 \
    --commission-max-rate=1.0 \
    --commission-rate=0.05

Collect Genesis Transactions

Gather all the genesis transactions:

junod collect-gentxs

Validate Genesis

Verify that your genesis file is valid:

junod validate-genesis

Launch the Chain

Once all the above steps have been completed, you can launch your blockchain:

junod start

Congratulations! You've successfully launched your own Cosmos SDK blockchain and validator node.