Ram | cpu | disk |
---|---|---|
8GB |
4Core |
500+ SSD |
sudo apt update
sudo apt install -y lz4 jq make git gcc build-essential curl chrony unzip gzip snapd tmux bc
# Install Go if you need
sudo rm -rf /usr/local/go
curl -L https://go.dev/dl/go1.21.6.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bash_profile
source .bash_profile
go version
Give your validator a name by which you can find yourself in explorer, put it in ""
MONIKER=""
After that, insert the following node installation command
# Clone project repository
cd $HOME
rm -rf 0g-chain
git clone https://github.com/0glabs/0g-chain.git
cd 0g-chain
git checkout v0.3.1
git submodule update --init
make install
# Set node CLI configuration
0gchaind config chain-id zgtendermint_16600-2
0gchaind config keyring-backend test
0gchaind config node tcp://localhost:26657
# Initialize the node
0gchaind init "$MONIKER" --chain-id zgtendermint_16600-2
# Download genesis and addrbook files
wget https://snapshots-testnet.unitynodes.com/0gchain-testnet/addrbook.json -O $HOME/.0gchain/config/addrbook.json
wget https://snapshots-testnet.unitynodes.com/0gchain-testnet/genesis.json -O $HOME/.0gchain/config/genesis.json
# Set seeds, peers
PEERS="[email protected]:26656,[email protected]:12656,[email protected]:12656,[email protected]:26656,[email protected]:12656,[email protected]:26656,[email protected]:26656,[email protected]:26646,[email protected]:13456,[email protected]:12656,[email protected]:12656,[email protected]:26656,[email protected]:12656,[email protected]:12656,[email protected]:26656"
SEEDS="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656"
sed -i 's|^seeds *=.*|seeds = "'$SEEDS'"|; s|^persistent_peers *=.*|persistent_peers = "'$PEERS'"|' $HOME/.0gchain/config/config.toml
# Set minimum gas price
sed -i "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0ua0gi\"/" $HOME/.0gchain/config/app.toml
# Set pruning
pruning="custom"
pruning_keep_recent="100"
pruning_keep_every="0"
pruning_interval="50"
sed -i -e "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-every *=.*/pruning-keep-every = \"$pruning_keep_every\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME/.0gchain/config/app.toml
# Download latest chain data snapshot
curl https://snapshots-testnet.unitynodes.com/0gchain-testnet/0gchain-testnet-latest.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.0gchain
# Create service
sudo tee /etc/systemd/system/0gchaind.service > /dev/null << EOF
[Unit]
Description=0G node service
After=network-online.target
[Service]
User=$USER
ExecStart=$(which 0gchaind) start
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
### Start service and run node
echo ""
printColor blue "[6/6] Start service and run node"
sudo systemctl daemon-reload
sudo systemctl enable 0gchaind.service
sudo systemctl start 0gchaind.service
Follow the commands to check if your node is working properly
- Check version
0gchaind version
- View sync status
local_height=$(0gchaind status | jq -r .sync_info.latest_block_height); network_height=$(curl -s https://rpc.0gchain-testnet.unitynodes.com/status | jq -r .result.sync_info.latest_block_height); blocks_left=$((network_height - local_height)); echo "Your node height: $local_height"; echo "Network height: $network_height"; echo "Blocks left: $blocks_left"
Blocks left - 0-1 everything is fine and your node catches up with the last block of the network.
- Check logs
tail -f -n 100 $HOME/.0gchain/log/chain.log
If your node is installed and fully synchronized with the network, proceed with the creation of the validator.
0gchaind keys add wallet --eth
!Save all information after entering the command, without this you will not be able to restore data to the wallet. SAVE SEED PHRASE (12 words).
Or if you had it before you can recover
- Replace WALLET_NAME
0gchaind keys add WALLET_NAME --eth --recover
We request the private key from our EVM address
0gchaind keys unsafe-export-eth-key wallet # or your wallet name
Press Y and enter We keep this private key with us Go to the metamask and import the wallet using it: We open the Faucet 0G Link 🚰 and request tokens to the metamask address we received
0gchaind q bank balances $(0gchaind keys show $WALLET_NAME -a)
Replace YOUR_WALLET with your wallet name
0gchaind tx staking create-validator \
--amount 1000000ua0gi \
--chain-id=zgtendermint_16600-2 \
--pubkey $(0gchaind tendermint show-validator) \
--moniker "$NODE_MONIKER" \
--identity "" \
--website "" \
--details "" \
--commission-rate 0.1 \
--commission-max-rate 0.2 \
--commission-max-change-rate 0.01 \
--min-self-delegation 1 \
--from YOUR_WALLET \
--gas-prices=0.25ua0gi \
--gas-adjustment=1.5 \
--gas=auto \
-y
cat $HOME/.0gchain/config/priv_validator_key.json
0gchaind tx staking delegate $(0gchaind keys show WALLET_NAME --bech val -a) 1000000ua0gi --from WALLET_NAME -y
- Replace WALLET_NAME
0gchaind tx slashing unjail --from WALLET_NAME --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto --gas-prices 0.00252ua0gi -y
0gchaind q staking validators -o json --limit=1000 \
| jq '.validators[] | select(.status=="BOND_STATUS_BONDED")' \
| jq -r '.tokens + " - " + .description.moniker' \
| sort -gr | nl
0gchaind q staking validators -o json --limit=1000 \
| jq '.validators[] | select(.status=="BOND_STATUS_UNBONDED")' \
| jq -r '.tokens + " - " + .description.moniker' \
| sort -gr | nl
0gchaind q bank balances $(0gchaind keys show WALLET_NAME -a)
0gchaind q staking validator $(0gchaind keys show WALLET_NAME --bech val -a)
sudo systemctl stop 0gchaind.service
sudo systemctl disable 0gchaind.service
sudo rm /etc/systemd/system/0gchaind.service
rm -rf $HOME/.0gchain $HOME/0g-chain