Learn how to run your 0G Node or Validator

Node Guide

Learn how to run your 0G Node or Validator

As the traditional way of running node is very well covered in the official docs and by other community member, we only focus on running node using Docker.

we have developed a docker setup to easily run a node without dealing with build requirements, systemd and opening firewall ports.

Requirements

You need a linux machine with docker installed on it. many VPS providers have an option to setup Docker through order interface, otherwise you should install it manually.

The official docker docs are pretty straight forward

Run the node using docker

Clone 0G-docker repository on your server

copy .env.sample to .env and fill it with your variables

build the image

docker compose --profile node build

run and exec into an ephemeral container:

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

inside the container run init script

/init.sh

if you want 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

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 and run node service in background

docker compose --profile node up -d

Restore snapshot or use state sync

first stop the running service

docker compose stop node

run an ephemeral container again

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

inside this container run your snapshot/state sync commands, then exit and run service again

docker compose up -d

Run arbitrary commands inside the node container

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

docker compose exec node bash

here you have access to 0gchaind binary

Storage Node

modify the variables in .env file under Storage configs section with your desired variables.

Important ones are:

  • STORAGE_MINER_PRIVATE_KEY This requires a private without key funded by testnet tokens from faucet. you have two ways to get this private key

    • create a fresh wallet on metamask, export private key and REMOVE LEADING 0X

    • or use your validator account private key. export it by 0gchaind keys unsafe-export-eth-key $WALLET_NAME

  • STORAGE_ENR_ADDRESS Your server public IP address

  • STORAGE_BLOCKCHAIN_RPC_ENDPOINT If you are running a node/validator using this compose file, you can directly connect to it by setting this to http://node:8545 , otherwise use a public RPC endpoint

build the image

docker compose --profile storage build

run the container in background

docker compose --profile storage up -d storage-node

check logs

docker compose --profile storage logs -f --since 1m storage-node

make sure wallet is funded by a0gi

KV Node

modify the variables in .env file under Storage configs section with your desired variables.

Important ones are:

  • STORAGE_BLOCKCHAIN_RPC_ENDPOINT If you are running a node/validator using this compose file, you can directly connect to it by setting this to http://node:8545 , otherwise use a public RPC endpoint

  • KV_ZGS_NODE_URLS If you are running a storage node using this compose file, you can directly connect to it by setting this to http://storage-node:5678 , otherwise use a public Storage node RPC endpoint

build the image

docker compose --profile kv build

run the container in background

docker compose --profile kv up -d kv-node

check logs

docker compose --profile kv logs -f --since 1m kv-node

Subscribe to Oryaniannerr
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.