Skip to content

0G Chain Validator Node Installation Guide

This guide provides the necessary steps to deploy a 0G Chain validator node. It covers dependency installation, binary compilation, node synchronization, and validator creation for the zgtendermint_16600-2 testnet.

Before beginning the installation, ensure your system meets the following minimum requirements:

  • Operating System: Ubuntu 22.04 LTS or higher
  • CPU: 4+ Cores
  • RAM: 8GB+
  • Storage: 500GB+ SSD
  • Network: 100Mbps+ bandwidth

Update the local package index and install the required build dependencies for Go-based blockchain software.

Terminal window
sudo apt update && \
sudo apt install curl git jq build-essential gcc unzip wget lz4 -y

0G Chain requires Go version 1.22.0 or higher.

Terminal window
cd $HOME && \
ver="1.22.0" && \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \
rm "go$ver.linux-amd64.tar.gz" && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile && \
source ~/.bash_profile && \
go version

Clone the official repository and build the 0gchaind binary from source.

Terminal window
git clone -b v0.3.0 https://github.com/0glabs/0g-chain.git
cd 0g-chain
make install
0gchaind version

Define your environment variables to streamline the initialization process. Replace My_Node with your preferred moniker.

Terminal window
echo 'export MONIKER="My_Node"' >> ~/.bash_profile
echo 'export CHAIN_ID="zgtendermint_16600-2"' >> ~/.bash_profile
echo 'export WALLET_NAME="wallet"' >> ~/.bash_profile
echo 'export RPC_PORT="26657"' >> ~/.bash_profile
source $HOME/.bash_profile

Initialize the configuration files and set the default keyring backend.

Terminal window
cd $HOME
0gchaind init $MONIKER --chain-id $CHAIN_ID
0gchaind config chain-id $CHAIN_ID
0gchaind config node tcp://localhost:$RPC_PORT
0gchaind config keyring-backend os

Download the genesis file and configure seed nodes to allow your node to discover peers.

Terminal window
wget https://github.com/0glabs/0g-chain/releases/download/v0.2.3/genesis.json -O $HOME/.0gchain/config/genesis.json
SEEDS="81987895a11f6689ada254c6b57932ab7ed909b6@54.241.167.190:26656,010fb4de28667725a4fef26cdc7f9452cc34b16d@54.176.175.48:26656,e9b4bc203197b62cc7e6a80a64742e752f4210d5@54.193.250.204:26656,68b9145889e7576b652ca68d985826abd46ad660@18.166.164.232:26656"
sed -i.bak -e "s/^seeds *=.*/seeds = \"${SEEDS}\"/" $HOME/.0gchain/config/config.toml

The following script updates config.toml and app.toml with standard port assignments and detects your external IP for P2P communication.

Terminal window
EXTERNAL_IP=$(wget -qO- eth0.me)
PROXY_APP_PORT=26658
P2P_PORT=26656
PPROF_PORT=6060
API_PORT=1317
GRPC_PORT=9090
GRPC_WEB_PORT=9091
# Update config.toml
sed -i \
-e "s/\(proxy_app = \"tcp:\/\/\)\([^:]*\):\([0-9]*\).*/\1\2:$PROXY_APP_PORT\"/" \
-e "s/\(laddr = \"tcp:\/\/\)\([^:]*\):\([0-9]*\).*/\1\2:$RPC_PORT\"/" \
-e "s/\(pprof_laddr = \"\)\([^:]*\):\([0-9]*\).*/\1localhost:$PPROF_PORT\"/" \
-e "/\[p2p\]/,/^\[/{s/\(laddr = \"tcp:\/\/\)\([^:]*\):\([0-9]*\).*/\1\2:$P2P_PORT\"/}" \
-e "/\[p2p\]/,/^\[/{s/\(external_address = \"\)\([^:]*\):\([0-9]*\).*/\1${EXTERNAL_IP}:$P2P_PORT\"/; t; s/\(external_address = \"\).*/\1${EXTERNAL_IP}:$P2P_PORT\"/}" \
$HOME/.0gchain/config/config.toml
# Update app.toml
sed -i \
-e "/\[api\]/,/^\[/{s/\(address = \"tcp:\/\/\)\([^:]*\):\([0-9]*\)\(\".*\)/\1\2:$API_PORT\4/}" \
-e "/\[grpc\]/,/^\[/{s/\(address = \"\)\([^:]*\):\([0-9]*\)\(\".*\)/\1\2:$GRPC_PORT\4/}" \
-e "/\[grpc-web\]/,/^\[/{s/\(address = \"\)\([^:]*\):\([0-9]*\)\(\".*\)/\1\2:$GRPC_WEB_PORT\4/}" \
-e "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0ua0gi\"/" \
$HOME/.0gchain/config/app.toml

To reduce disk usage, you can enable custom pruning settings.

Terminal window
sed -i \
-e "s/^pruning *=.*/pruning = \"custom\"/" \
-e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" \
-e "s/^pruning-interval *=.*/pruning-interval = \"10\"/" \
"$HOME/.0gchain/config/app.toml"

Create a systemd service file to ensure the node runs in the background and restarts automatically on failure.

Terminal window
sudo tee /etc/systemd/system/0gd.service > /dev/null <<EOF
[Unit]
Description=0G Node
After=network.target
[Service]
User=$USER
Type=simple
ExecStart=$(which 0gchaind) start --home $HOME/.0gchain
Restart=on-failure
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable 0gd
sudo systemctl start 0gd

Check the node’s logs and synchronization progress. The node is ready for validator operations only when catching_up is false.

Terminal window
# View logs
sudo journalctl -u 0gd -f -o cat
# Check sync status
0gchaind status | jq '{ latest_block_height: .sync_info.latest_block_height, catching_up: .sync_info.catching_up }'

Create a new wallet or restore an existing one. Ensure you securely back up your mnemonic phrase.

Terminal window
0gchaind keys add $WALLET_NAME --eth

To interact with the EVM-compatible faucet, extract your 0x address:

Terminal window
echo "0x$(0gchaind debug addr $(0gchaind keys show $WALLET_NAME -a) | grep hex | awk '{print $3}')"

Note: Request testnet tokens from the 0G Faucet before proceeding.

Once the node is fully synced and funded, execute the following command to register your validator.

Terminal window
0gchaind tx staking create-validator \
--amount=1000000ua0gi \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker="$MONIKER" \
--chain-id=zgtendermint_16600-2 \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--details="0G infrastructure provider" \
--min-self-delegation="1" \
--from="$WALLET_NAME" \
--gas=auto \
--gas-adjustment=1.4 \
-y

When the network reaches a scheduled upgrade height (e.g., block 574000), follow these steps to update the binary.

Terminal window
cd $HOME
wget -O 0gchaind https://zgchaind-test.s3.ap-east-1.amazonaws.com/0gchaind-linux-v0.3.0
chmod +x $HOME/0gchaind
sudo mv $HOME/0gchaind $(which 0gchaind)
sudo systemctl restart 0gd
TaskCommand
Check Balance0gchaind q bank balances $(0gchaind keys show $WALLET_NAME -a)
RPC Connectivitycurl -X POST http://localhost:8545 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
Validator StatusCheck moniker in 0G Explorer