Nodes Guide

Fullnode & Validator

Learn how to run your 0G-ZeroGravity Node or Validator with Cosmovisor support out of the box

Prerequisites

You have completed Getting Started with ZeroGravity

Set environment variables

This repository is for testnet at the moment. all keys are stored in the test keyring backend, keys stored on the other backends will be lost during container recreation

open .env file with your editor

nano .env

edit variables under 0G Node Config section. set your desired variables.

  • MONIKER A name for your node, will be public to others
  • WALLET_NAME can be any name, stored locally
  • SEEDS address of seed nodes
  • PERSISTENT_PEERS comma separated list of persistent peers
  • WALLET_NAME can be any name, stored locally
  • EXTERNAL_IP your server public IP address
  • P2P_PORT set a valid, non-busy port - default is 26656
  • RPC_PORT set a valid, non-busy port - default is 26657
  • API_JSON_RPC_PORT EVM RPC public port. set a valid, non-busy port - default is 8545
  • LCD_PORT API port. set a valid, non-busy port - default is 1317
you should restart your container everytime you change an environment variable
You don't have to open above ports on the firewall. just exposing them is enough to be accessible from outside world

Initialize network

run and exec into an ephemeral container:

docker compose --profile node run --rm --entrypoint /bin/bash node

now we are inside the container, run the init script.
this will download genesis files and set required configs for this container to work

/init.sh

if you want to modify config files further edit the config manually

nano $HOME/.0gchain/config/config.toml

then create a new wallet or import one

0gchaind keys add $WALLET_NAME --recover --eth
MAKE A BACKUP YOUR MNEMONIC PHRASE KEY!

to import your previous node_key.json or other files you can either :

  • use docker cp command in another terminal to copy your files
  • or manually edit files using nano and replace the content of your keys with your backups

Now exit the container using Ctrl+D

Run Node container

and run node service in background

docker compose --profile node up -d

then check logs

docker compose --profile node logs -f --tail 100
If you want to quickly sync with the network you can our Snapshot or StateSync services. also use our realtime updated Address Book

Run commands inside the node container

to run any commands using 0gchaind, just exec into running node container

docker compose --profile node exec node bash

then run any commands you want normally, like 0gchaind status.
when you are done, exit the container using ctrl+D

if you don't have plan to run a Fullnode on 0G , but still want to have access to 0gchaind binary to run some commands like creating a wallet or query the blockchain, you can use ephemeral containers (they live as long as you are inside them, then will get removed)
docker compose --profile node run --rm --entrypoint /bin/bash node

Become Validator

to become validator, first make sure your node is fully synced. first enter the container by running:

docker compose --profile node exec node bash

check sync status

0gchaind status | jq

get your wallet EVM address

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

use this address on faucet website.

create validator, replace <staking_amount> with your desired amount. e.g. 10ua0gi

0gchaind tx staking create-validator \
  --amount=<staking_amount>ua0gi \
  --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" \
  --min-self-delegation="1" \
  --from=$WALLET_NAME \
  --gas=auto \
  --gas-adjustment=1.4