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.
Prerequisites
Section titled “Prerequisites”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
System Preparation
Section titled “System Preparation”Update the local package index and install the required build dependencies for Go-based blockchain software.
sudo apt update && \sudo apt install curl git jq build-essential gcc unzip wget lz4 -yInstall Go Environment
Section titled “Install Go Environment”0G Chain requires Go version 1.22.0 or higher.
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 versionBinary Installation
Section titled “Binary Installation”Clone the official repository and build the 0gchaind binary from source.
git clone -b v0.3.0 https://github.com/0glabs/0g-chain.gitcd 0g-chainmake install0gchaind versionNode Configuration
Section titled “Node Configuration”Define your environment variables to streamline the initialization process. Replace My_Node with your preferred moniker.
echo 'export MONIKER="My_Node"' >> ~/.bash_profileecho 'export CHAIN_ID="zgtendermint_16600-2"' >> ~/.bash_profileecho 'export WALLET_NAME="wallet"' >> ~/.bash_profileecho 'export RPC_PORT="26657"' >> ~/.bash_profilesource $HOME/.bash_profileInitialize Node
Section titled “Initialize Node”Initialize the configuration files and set the default keyring backend.
cd $HOME0gchaind init $MONIKER --chain-id $CHAIN_ID0gchaind config chain-id $CHAIN_ID0gchaind config node tcp://localhost:$RPC_PORT0gchaind config keyring-backend osNetwork and Genesis Setup
Section titled “Network and Genesis Setup”Download the genesis file and configure seed nodes to allow your node to discover peers.
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.tomlPort Configuration
Section titled “Port Configuration”The following script updates config.toml and app.toml with standard port assignments and detects your external IP for P2P communication.
EXTERNAL_IP=$(wget -qO- eth0.me)PROXY_APP_PORT=26658P2P_PORT=26656PPROF_PORT=6060API_PORT=1317GRPC_PORT=9090GRPC_WEB_PORT=9091
# Update config.tomlsed -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.tomlsed -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.tomlStorage Optimization (Optional)
Section titled “Storage Optimization (Optional)”To reduce disk usage, you can enable custom pruning settings.
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"Service Management
Section titled “Service Management”Create a systemd service file to ensure the node runs in the background and restarts automatically on failure.
sudo tee /etc/systemd/system/0gd.service > /dev/null <<EOF[Unit]Description=0G NodeAfter=network.target
[Service]User=$USERType=simpleExecStart=$(which 0gchaind) start --home $HOME/.0gchainRestart=on-failureLimitNOFILE=65535
[Install]WantedBy=multi-user.targetEOF
sudo systemctl daemon-reloadsudo systemctl enable 0gdsudo systemctl start 0gdMonitoring Sync Status
Section titled “Monitoring Sync Status”Check the node’s logs and synchronization progress. The node is ready for validator operations only when catching_up is false.
# View logssudo journalctl -u 0gd -f -o cat
# Check sync status0gchaind status | jq '{ latest_block_height: .sync_info.latest_block_height, catching_up: .sync_info.catching_up }'Wallet Setup
Section titled “Wallet Setup”Create a new wallet or restore an existing one. Ensure you securely back up your mnemonic phrase.
0gchaind keys add $WALLET_NAME --ethTo interact with the EVM-compatible faucet, extract your 0x address:
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.
Validator Creation
Section titled “Validator Creation”Once the node is fully synced and funded, execute the following command to register your validator.
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 \-yMaintenance and Upgrades
Section titled “Maintenance and Upgrades”When the network reaches a scheduled upgrade height (e.g., block 574000), follow these steps to update the binary.
cd $HOMEwget -O 0gchaind https://zgchaind-test.s3.ap-east-1.amazonaws.com/0gchaind-linux-v0.3.0chmod +x $HOME/0gchaindsudo mv $HOME/0gchaind $(which 0gchaind)sudo systemctl restart 0gdVerification Tasks
Section titled “Verification Tasks”| Task | Command |
|---|---|
| Check Balance | 0gchaind q bank balances $(0gchaind keys show $WALLET_NAME -a) |
| RPC Connectivity | curl -X POST http://localhost:8545 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' |
| Validator Status | Check moniker in 0G Explorer |