# 0g Node Setup Guide **Published by:** [Nofena99](https://paragraph.com/@nofena99/) **Published on:** 2024-08-15 **URL:** https://paragraph.com/@nofena99/0g-node-setup-guide ## Content Install required packagessudo apt update && \ sudo apt install curl git jq build-essential gcc unzip wget lz4 -y Install Gocd $HOME && \ ver="1.21.3" && \ 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 Build evmosd Binarywget https://rpc-zero-gravity-testnet.nofena99.org/evmosd chmod +x ./evmosd mv ./evmosd /usr/local/bin/ evmosd version Set Up VariablesCustomize if you needecho 'export MONIKER="test"' >> ~/.bash_profile echo 'export CHAIN_ID="zgtendermint_9000-1"' >> ~/.bash_profile echo 'export WALLET_NAME="wallet"' >> ~/.bash_profile echo 'export RPC_PORT="26657"' >> ~/.bash_profile source $HOME/.bash_profile Initialize the Nodecd $HOME evmosd init $MONIKER --chain-id $CHAIN_ID evmosd config chain-id $CHAIN_ID evmosd config node tcp://localhost:$RPC_PORT evmosd config keyring-backend os Download genesis.jsonwget https://rpc-zero-gravity-testnet.nofena99.org/genesis.json -O $HOME/.evmosd/config/genesis.json Add Seeds and Peers to the config.tomlPEERS="1248487ea585730cdf5d3c32e0c2a43ad0cda973@peer-zero-gravity-testnet.nofena99.org:26326" && \ SEEDS="8c01665f88896bca44e8902a30e4278bed08033f@54.241.167.190:26656,b288e8b37f4b0dbd9a03e8ce926cd9c801aacf27@54.176.175.48:26656,8e20e8e88d504e67c7a3a58c2ea31d965aa2a890@54.193.250.204:26656,e50ac888b35175bfd4f999697bdeb5b7b52bfc06@54.215.187.94:26656" && \ sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.evmosd/config/config.toml Optional. Change PortsEXTERNAL_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 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/.evmosd/config/config.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/}" $HOME/.evmosd/config/app.toml Optional. Configure Prunning to Save Storagesed -i.bak -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.evmosd/config/app.toml sed -i.bak -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.evmosd/config/app.toml sed -i.bak -e "s/^pruning-interval *=.*/pruning-interval = \"10\"/" $HOME/.evmosd/config/app.toml Set Minimum Gas Pricesed -i "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0.00252aevmos\"/" $HOME/.evmosd/config/app.toml Optional. Enable indexersed -i "s/^indexer *=.*/indexer = \"kv\"/" $HOME/.evmosd/config/config.toml Create a Service filesudo tee /etc/systemd/system/ogd.service > /dev/null << EOF [Unit] Description=OG Node After=network.target [Service] User=$USER Type=simple ExecStart=$(which evmosd) start --home $HOME/.evmosd Restart=on-failure LimitNOFILE=65535 [Install] WantedBy=multi-user.target EOF Start the Nodesudo systemctl daemon-reload && sudo systemctl enable ogd && sudo systemctl restart ogd && sudo journalctl -u ogd -f -o cat Download Snapshotwget https://rpc-zero-gravity-testnet.nofena99.org/latest_snapshot.tar.lz4 Stop the nodesudo systemctl stop ogd Backup priv_validator_state.jsoncp $HOME/.evmosd/data/priv_validator_state.json $HOME/.evmosd/priv_validator_state.json.backup Reset DBevmosd tendermint unsafe-reset-all --home $HOME/.evmosd --keep-addr-book Extract files fromt the arvhivelz4 -d -c ./latest_snapshot.tar.lz4 | tar -xf - -C $HOME/.evmosd Move priv_validator_state.json backmv $HOME/.evmosd/priv_validator_state.json.backup $HOME/.evmosd/data/priv_validator_state.json Restart the nodesudo systemctl restart ogd && sudo journalctl -u ogd -f -o cat Create a Wallet for Your Validatorevmosd keys add $WALLET_NAME !Note: save seed pharse. If you don't save the seed pharse you can't get it back if you want to recover wallet use command:evmosd keys add $WALLET_NAME --recover Extract the HEX Address to Request Some Tokens from the Faucetecho "0x$(evmosd debug addr $(evmosd keys show $WALLET_NAME -a) | grep hex | awk '{print $3}')" You can extract the private keys in address above, use command:evmosd keys unsafe-export-eth-key $WALLET_NAME You can add account with private keys in metamask, account use faucet token if you want. Save private keys add to metamask to faucet tokenFaucet Tokenhttps://faucet.0g.ai/ Note: The faucet gives you 100000000000000000aevmos. To make the validator join the active set you need at least 1000000000000000000aevmos (10 times more)Check Wallet Balancesevmosd q bank balances $(evmosd keys show $WALLET_NAME -a) Check if Node Syncedevmosd status | jq .SyncInfo.catching_up If your node synced ("catching_up"=False) you can create validatorCreate a Validatorevmosd tx staking create-validator \ --amount=10000000000000000aevmos \ --pubkey=$(evmosd tendermint show-validator) \ --moniker=$MONIKER \ --chain-id=$CHAIN_ID \ --commission-rate=0.05 \ --commission-max-rate=0.10 \ --commission-max-change-rate=0.01 \ --min-self-delegation=1 \ --from=$WALLET_NAME \ --gas=500000 --gas-prices=99999aevmos \ -y You can check your Validator status here. Please allow some time for your validator to be added to the 0G Validator list.Backup Validator Keyscp $HOME/.evmosd/data/priv_validator_state.json $HOME/.evmosd/priv_validator_state.json.backup Check After Validator Createdevmosd q staking validator $(evmosd keys show $WALLET_NAME --bech val -a) ## Publication Information - [Nofena99](https://paragraph.com/@nofena99/): Publication homepage - [All Posts](https://paragraph.com/@nofena99/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@nofena99): Subscribe to updates - [Twitter](https://twitter.com/nofena99): Follow on Twitter