Skip to content

Og

Installation

Terminal window
# install dependencies, if needed
sudo apt update && sudo apt upgrade -y
sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip -y
Terminal window
# install go, if needed
cd $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"
[ ! -f ~/.bash_profile ] && touch ~/.bash_profile
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bash_profile
source $HOME/.bash_profile
[ ! -d ~/go/bin ] && mkdir -p ~/go/bin
# set vars
echo "export WALLET="wallet"" >> $HOME/.bash_profile
echo "export MONIKER="test"" >> $HOME/.bash_profile
echo "export OG_CHAIN_ID="zgtendermint_16600-2"" >> $HOME/.bash_profile
echo "export OG_PORT="47"" >> $HOME/.bash_profile
source $HOME/.bash_profile
# download binary
# download binary
cd $HOME
rm -rf 0g-chain
wget -O 0gchaind https://github.com/0glabs/0g-chain/releases/download/v0.5.0/0gchaind-linux-v0.5.0
chmod +x $HOME/0gchaind
sudo mv $HOME/0gchaind $HOME/go/bin
# config and init app
0gchaind config node tcp://localhost:${OG_PORT}657
0gchaind config keyring-backend os
0gchaind config chain-id zgtendermint_16600-2
0gchaind init "test" --chain-id zgtendermint_16600-2
# download genesis and addrbook
wget -O $HOME/.0gchain/config/genesis.json https://server-5.itrocket.net/testnet/og/genesis.json
wget -O $HOME/.0gchain/config/addrbook.json https://server-5.itrocket.net/testnet/og/addrbook.json
# set seeds and peers
SEEDS="bac83a636b003495b2aa6bb123d1450c2ab1a364@og-testnet-seed.itrocket.net:47656"
PEERS="80fa309afab4a35323018ac70a40a446d3ae9caf@og-testnet-peer.itrocket.net:11656,18f59d3b0604657ef973455ca2a54288fb90a1e0@144.91.124.119:12656,c56ecb9d3c15719fd4fa3eb4d56a1dbcf247c200@144.91.69.99:12656,507dfd2777b0577c3f9b93aef2e5d11fc0804854@144.91.104.84:12656,87102a77fd10ddbcfdd8357a08f4d4578a80d639@62.169.20.160:12656,67719109abbd563b536268bd19ec3d6bea120b75@62.171.138.207:12656,d4a3d3ab4911dc9cd1ad58bbfff2ccc22c82c2f7@109.199.115.109:12656,f300a77123e2afe4115e229a9f9a561ef2bf03fb@157.173.120.105:12656,8af00959d5a49081277e7a59bf6522aa5b35e878@84.54.23.162:26656,211da449bf73bca321c08a4c00bb2541d1d6d126@109.123.248.230:12656,349c6ede8c9d03a9ac4e8dcc2a854556af219cdb@62.171.156.207:12656,9ef3f3fb2a0d4d9c5446d3028be850b92c7ea775@134.255.177.194:12656,4d143c2cf1a6cb26ffbee54da4b49ca179adffcb@38.242.213.130:12656,723cae01407afb7e1377ddacf6fc9e06e49d92eb@195.26.252.20:47656,807344c15bb1b825451c8c06222d8a206b223a95@75.119.149.49:12656,edae998fc9918f67b3ad42c9843ab0bc12379ead@38.242.202.218:12656,d6db064420bad77c70ba62e4e343ebb7e4b53a96@161.97.101.241:12656,342c70d258f65cfa662a1a8e3215627d7c670053@84.46.248.204:26656,cef87fd357bea480148f6b529f1d3c88c41482dd@84.247.175.133:12656,528be33d5999f78f0b2f4a8986520702f8de804a@161.97.120.111:12656,11e3cef877e74cddc75f290206c7d0f126f6163f@161.97.118.229:12656"
sed -i -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*seeds *=.*/seeds = \"$SEEDS\"/}" \
-e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \"$PEERS\"/}" $HOME/.0gchain/config/config.toml
# set custom ports in app.toml
sed -i.bak -e "s%:1317%:${OG_PORT}317%g;
s%:8080%:${OG_PORT}080%g;
s%:9090%:${OG_PORT}090%g;
s%:9091%:${OG_PORT}091%g;
s%:8545%:${OG_PORT}545%g;
s%:8546%:${OG_PORT}546%g;
s%:6065%:${OG_PORT}065%g" $HOME/.0gchain/config/app.toml
# set custom ports in config.toml file
sed -i.bak -e "s%:26658%:${OG_PORT}658%g;
s%:26657%:${OG_PORT}657%g;
s%:6060%:${OG_PORT}060%g;
s%:26656%:${OG_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${OG_PORT}656\"%;
s%:26660%:${OG_PORT}660%g" $HOME/.0gchain/config/config.toml
# config pruning
sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"19\"/" $HOME/.0gchain/config/app.toml
# set minimum gas price, enable prometheus and disable indexing
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0ua0gi"|g' $HOME/.0gchain/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.0gchain/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.0gchain/config/config.toml
# create service file
sudo tee /etc/systemd/system/0gchaind.service > /dev/null <<EOF
[Unit]
Description=0G node
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/.0gchain
ExecStart=$(which 0gchaind) start --home $HOME/.0gchain --log_output_console
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
# reset and download snapshot
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain
curl https://server-5.itrocket.net/testnet/og/og_2025-02-22_3346550_snap.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.0gchain
# enable and start service
sudo systemctl daemon-reload
sudo systemctl enable 0gchaind
sudo systemctl restart 0gchaind && sudo journalctl -u 0gchaind -fo cat

Create Wallet

Terminal window
# to create a new wallet, use the following command. don’t forget to save the mnemonic
0gchaind keys add $WALLET
# to restore exexuting wallet, use the following command
0gchaind keys add $WALLET --recover
# save wallet and validator address
WALLET_ADDRESS=$(0gchaind keys show $WALLET -a)
VALOPER_ADDRESS=$(0gchaind keys show $WALLET --bech val -a)
echo "export WALLET_ADDRESS="$WALLET_ADDRESS >> $HOME/.bash_profile
echo "export VALOPER_ADDRESS="$VALOPER_ADDRESS >> $HOME/.bash_profile
source $HOME/.bash_profile
# check sync status, once your node is fully synced, the output from above will print "false"
0gchaind status 2>&1 | jq
# before creating a validator, you need to fund your wallet and check balance
0gchaind query bank balances $WALLET_ADDRESS

Create Validator

Terminal window
0gchaind tx staking create-validator \
--amount 1000000ua0gi \
--from $WALLET \
--commission-rate 0.1 \
--commission-max-rate 0.2 \
--commission-max-change-rate 0.01 \
--min-self-delegation 1 \
--pubkey $(0gchaind tendermint show-validator) \
--moniker "test" \
--identity "" \
--website "" \
--details "" \
--chain-id zgtendermint_16600-2 \
--gas=auto --gas-adjustment=1.6 --gas-prices 0.00252ua0gi \
-y