Testnet

0G Labs

Installation Guide
CLI Command
Public Endpoint
Statesync
Snapshot
Explorers
Node Maps
Installation Guide
Installation Guide
CLI Command
Public Endpoint
Statesync
Snapshot
Explorers
Node Maps

How To Install Full Node 0G Testnet

Setting up vars

Your Nodename (validator) that will shows in explorer

NODENAME=<Your_Nodename_Moniker>

Save variables to system

echo "export NODENAME=$NODENAME" >> $HOME/.bash_profile
if [ ! $WALLET ]; then
    echo "export WALLET=wallet" >> $HOME/.bash_profile
fi
echo "export OG_CHAIN_ID=zgtendermint_16600-1" >> $HOME/.bash_profile
source $HOME/.bash_profile

Update packages

sudo apt update && sudo apt upgrade -y

Install dependencies

sudo apt install curl build-essential git wget jq make gcc tmux net-tools ccze -y

Install go

if ! [ -x "$(command -v go)" ]; then
  ver="1.20.2"
  cd $HOME
  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
fi

Download and build binaries

cd $HOME
git clone -b v0.1.0 https://github.com/0glabs/0g-chain.git
./0g-chain/networks/testnet/install.sh
source ~/.profile
0gchaind version

Config app

0gchaind config chain-id $OG_CHAIN_ID

Init app

0gchaind init $NODENAME --chain-id $OG_CHAIN_ID

Download configuration

cd $HOME
curl -Ls https://snap1.konsortech.xyz/0gchain/genesis.json > $HOME/.0gchain/config/genesis.json
curl -Ls https://snap1.konsortech.xyz/0gchain/addrbook.json > $HOME/.0gchain/config/addrbook.json

Disable indexing

indexer="null"
sed -i -e "s/^indexer *=.*/indexer = \"$indexer\"/" $HOME/.0gchain/config/config.toml

Config pruning

sed -i 's|pruning = "default"|pruning = "custom"|g' $HOME/.0gchain/config/app.toml
sed -i 's|pruning-keep-recent = "0"|pruning-keep-recent = "100"|g' $HOME/.0gchain/config/app.toml
sed -i 's|pruning-interval = "0"|pruning-interval = "10"|g' $HOME/.0gchain/config/app.toml

Set minimum gas price

sed -i 's|^minimum-gas-prices *=.*|minimum-gas-prices = "0ua0gi"|g' $HOME/.0gchain/config/app.toml

Create service

sudo tee /etc/systemd/system/0gchaind.service > /dev/null << EOF
[Unit]
Description=0G Node
After=network-online.target
[Service]
User=$USER
ExecStart=$(which 0gchaind) start
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF

Register and start service

sudo systemctl daemon-reload
sudo systemctl enable 0gchaind
sudo systemctl restart 0gchaind && sudo journalctl -u 0gchaind -f -o cat

Guide for Validator CLI

Create wallet

To create new wallet you can use command below. Don’t forget to save the mnemonic

0gchaind keys add $WALLET

To recover your wallet using seed phrase

0gchaind keys add $WALLET --recover

Show your wallet list

0gchaind keys list

Save wallet info

Add wallet and validator address into variables

OG_WALLET_ADDRESS=$(0gchaind keys show $WALLET -a)
OG_VALOPER_ADDRESS=$(0gchaind keys show $WALLET --bech val -a)
echo 'export OG_WALLET_ADDRESS='${OG_WALLET_ADDRESS} >> $HOME/.bash_profile
echo 'export OG_VALOPER_ADDRESS='${OG_VALOPER_ADDRESS} >> $HOME/.bash_profile
source $HOME/.bash_profile

Fund your wallet

Check Your Evm Wallet

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

Faucet available on website

https://faucet.0g.ai/

Create validator

check your wallet balance:

0gchaind query bank balances $OG_WALLET_ADDRESS

To create your validator run command below

0gchaind tx staking create-validator \
  --amount 1000000ua0gi \
  --from $WALLET \
  --commission-max-change-rate "0.01" \
  --commission-max-rate "0.2" \
  --commission-rate "0.1" \
  --min-self-delegation "1" \
  --pubkey $(0gchaind tendermint show-validator) \
  --moniker $NODENAME \
  --chain-id $OG_CHAIN_ID
  --gas-prices=0.25ua0gi  \
  --gas-adjustment=1.5 \
  --gas=auto 

Check your validator key

[[ $(0gchaind q staking validator $OG_VALOPER_ADDRESS -oj | jq -r .consensus_pubkey.key) = $(0gchaind status | jq -r .validator_info.PubKey.value) ]] && echo -e "\n\e[1m\e[32mTrue\e[0m\n" || echo -e "\n\e[1m\e[31mFalse\e[0m\n"

Get list of validators

0gchaind q staking validators -oj --limit=3000 | jq '.validators[] | select(.status=="BOND_STATUS_BONDED")' | jq -r '(.tokens|tonumber/pow(10; 6)|floor|tostring) + " \t " + .description.moniker' | sort -gr | nl

Usefull commands

Service management

Check logs

journalctl -fu 0gchaind -o cat

Start service

sudo systemctl start 0gchaind

Stop service

sudo systemctl stop 0gchaind

Restart service

sudo systemctl restart 0gchaind

Node info

Synchronization info

0gchaind status 2>&1 | jq .sync_info

Validator info

0gchaind status 2>&1 | jq .validator_info

Node info

0gchaind status 2>&1 | jq .node_info

Show node id

0gchaind tendermint show-node-id

Wallet operations

List of wallets

0gchaind keys list

Recover wallet

0gchaind keys add $WALLET --recover

Delete wallet

0gchaind keys delete $WALLET

Get wallet balance

0gchaind query bank balances $OG_WALLET_ADDRESS

Transfer funds

0gchaind tx bank send $OG_WALLET_ADDRESS <TO_OG_WALLET_ADDRESS> 1000000ua0gi

Voting

0gchaind tx gov vote 1 yes --from $WALLET --chain-id=$OG_CHAIN_ID

Staking, Delegation and Rewards

Delegate stake

0gchaind tx staking delegate $OG_VALOPER_ADDRESS 1000000ua0gi --from=$WALLET --chain-id=$OG_CHAIN_ID --gas=auto

Redelegate stake from validator to another validator

0gchaind tx staking redelegate <srcValidatorAddress> <destValidatorAddress> 1000000ua0gi --from=$WALLET --chain-id=$OG_CHAIN_ID --gas=auto

Withdraw all rewards

0gchaind tx distribution withdraw-all-rewards --from=$WALLET --chain-id=$OG_CHAIN_ID --gas=auto

Withdraw rewards with commision

0gchaind tx distribution withdraw-rewards $OG_VALOPER_ADDRESS --from=$WALLET --commission --chain-id=$OG_CHAIN_ID

Validator management

Edit validator

0gchaind tx staking edit-validator \
  --moniker=$NODENAME \
  --identity=<your_keybase_id> \
  --website="<your_website>" \
  --details="<your_validator_description>" \
  --chain-id=$OG_CHAIN_ID \
  --from=$WALLET

Unjail validator

0gchaind tx slashing unjail \
  --broadcast-mode=block \
  --from=$WALLET \
  --chain-id=$OG_CHAIN_ID \
  --gas=auto

Public Endpoints

RPC

https://testnet-og-rpc.konsortech.xyz

JSON EVM RPC

Network Name    : 0G Newton Testnet
RPC URL         : https://testnet-og-evm.konsortech.xyz
Chain ID        : 9000
Curreny Symbol  : A0GI

API

https://testnet-og-api.konsortech.xyz

gRPC

testnet-og.konsortech.xyz:20090

Persistence Peers

445f20cc15a24d8159cf491e542cc3ee779888b8@testnet-og.konsortech.xyz:20656

Seeds

@testnet-seed.konsortech.xyz:20165

State Sync

sudo systemctl stop 0gchaind

cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backup
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book

SNAP_RPC="https://testnet-og-rpc.konsortech.xyz:443"

LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \
BLOCK_HEIGHT=$((LATEST_HEIGHT - 1000)); \
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)

echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH

peers="445f20cc15a24d8159cf491e542cc3ee779888b8@testnet-og.konsortech.xyz:20656"
sed -i 's|^persistent_peers *=.*|persistent_peers = "'$peers'"|' $HOME/.0gchain/config/config.toml

sed -i -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.0gchain/config/config.toml

mv $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.json

sudo systemctl restart 0gchaind
sudo journalctl -u 0gchaind -f --no-hostname -o cat

Snapshot

sudo systemctl stop 0gchaind
cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backup
rm -rf $HOME/.0gchain/data

SNAP_NAME=$(curl -s https://snap1.konsortech.xyz/0gchain/ | egrep -o ">0gchain-snapshot.*\.tar.lz4" | tr -d ">")
curl https://snap1.konsortech.xyz/0gchain/${SNAP_NAME} | lz4 -dc - | tar -xf - -C $HOME/.0gchain
mv $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.json

sudo systemctl restart 0gchaind && journalctl -u 0gchaind -f --no-hostname -o cat
Embed Iframe

0G Labs Testnet Decentralization Maps