Resources
Hardware requirements
Installation 💾
Install dependencies
Copy sudo apt update && sudo apt upgrade -y
sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip -y
Install GO 1.22.2
Copy sudo rm -rf /usr/local/go && \
curl -L https://go.dev/dl/go1.22.2.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local && \
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bash_profile && \
source $HOME /.bash_profile && \
[ ! -d ~ /go/bin ] && mkdir -p ~/go/bin
go version
Set vars (change <wallet-name> and <moniker>)
Copy echo "export WALLET=" < WALLET_NAM E > "" >> $HOME /.bash_profile
echo "export MONIKER=" < MONIKE R > "" >> $HOME /.bash_profile
echo "export OG_CHAIN_ID=" zgtendermint_16600-2 "" >> $HOME /.bash_profile
source $HOME /.bash_profile
Get binary
Copy cd $HOME
rm -rf 0g-chain
wget -O 0gchaind https://github.com/0glabs/0g-chain/releases/download/v0.4.0/0gchaind-linux-v0.4.0
chmod +x $HOME /0gchaind
sudo mv $HOME /0gchaind $HOME /go/bin
0gchaind version
Set config and init
Copy 0gchaind config node tcp://localhost:26657
0gchaind config keyring-backend os
0gchaind config chain-id zgtendermint_16600-2
0gchaind init "<MONIKER>" --chain-id zgtendermint_16600-2
Get genesis
Copy wget -P $HOME /.0gchain/config https://github.com/0glabs/0g-chain/releases/download/v0.2.3/genesis.json
Add seeds and peers in config.toml
Copy SEEDS = "81987895a11f6689ada254c6b57932ab7ed909b6@54.241.167.190:26656,010fb4de28667725a4fef26cdc7f9452cc34b16d@54.176.175.48:26656,e9b4bc203197b62cc7e6a80a64742e752f4210d5@54.193.250.204:26656,68b9145889e7576b652ca68d985826abd46ad660@18.166.164.232:26656" && \
PEERS = "6122859577a3465ba67065f3b63194cae67ef4c4@110.171.123.186:36656" && \
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME /.0gchain/config/config.toml
Set minimum gas price. (Optional) Enable prometheus and disable indexing
Copy 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
(Optional) Pruning data
Copy 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 = \"50\"/" $HOME /.0gchain/config/app.toml
Create a service
Copy sudo tee /etc/systemd/system/0gd.service > /dev/null << EOF
[Unit]
Description=OG Node
After=network.target
[Service]
User=$USER
Type=simple
ExecStart=$( which 0gchaind) start --json-rpc.api eth,txpool,personal,net,debug,web3 --home $HOME/.0gchain
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
Environment="G0GC=900"
Environment="G0MELIMIT=40GB"
[Install]
WantedBy=multi-user.target
EOF
Copy sudo systemctl daemon-reload
Download and extract snapshot for fast sync
Create or recover wallet
Dont forget to save mnemonic
create wallet
Copy 0gchaind keys add $WALLET_NAME --eth
recover wallet
Copy 0gchaind keys add $WALLET_NAME --eth --recover
Set var wallet and validator addresses
Copy WALLET_ADDRESS = $( 0gchaind keys show $WALLET_NAME -a )
VALOPER_ADDRESS = $( 0gchaind keys show $WALLET_NAME --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
Request tokens from the faucet 🆓
The faucet gives you 1 A0GI = 1,000,000 ua0gi
Extract the HEX address to request some tokens from the faucet
Copy echo "0x$( 0gchaind debug addr $( 0gchaind keys show $WALLET_NAME -a ) | grep hex | awk '{print $3}')"
Copy https://faucet.0g.ai/
check balance
Copy 0gchaind query bank balances $WALLET_ADDRESS
Create a Validator
Copy 0gchaind tx staking create-validator \
--amount=1000000ua0gi \
--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" \
--details= "" \
--website= "" \
--min-self-delegation= "1" \
--from= "$WALLET_NAME" \
--gas=auto \
--gas-adjustment=1.4 \
-y
Useful commands ⚙️
Node status
Copy 0gchaind status 2>&1 | jq
Query your validator
Copy 0gchaind q staking validator $( 0gchaind keys show $WALLET_NAME --bech val -a )
Delegate tokens to your validator
Copy 0gchaind tx staking delegate $( 0gchaind keys show $WALLET_NAME --bech val -a ) 1000000ua0gi --from $WALLET_NAME --chain-id zgtendermint_16600-1 --gas=auto --gas-adjustment=1.6 -y
Delete node 🗑️
Copy sudo systemctl stop 0gd
sudo systemctl disable 0gd
sudo rm -rf /etc/systemd/system/0gd.service
sudo rm $( which 0gchaind )
sudo rm -rf $HOME /.0gchain
sed -i "/OG_/d" $HOME /.bash_profile