πŸ’‘ Useful commands

βš™οΈ Service Commands

Check Logs

tail -f -n 100 $HOME/.0gchain/log/chain.log

Start service

sudo systemctl start 0gchaind

Stop service

sudo systemctl stop 0gchaind

Restart service

sudo systmctl restart 0gchaind

Check status

sudo systemctl status 0gchaind

Enable Service

sudo systemctl enable 0gchaind

Reload service

sudo systemctl daemon-reload

Disable service

sudo systemctl disable 0gchaind

Check synchronization status

0gchaind status | jq | grep "catching_up"

If "true" - not synchronized // "false" - synchronized

Check the latest block of your validator and the last block of the network

while true; do 
  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 -e "\033[1;33m[Sync Status]\033[0m \033[1;32mNode Height:\033[0m \033[1;37m$local_height\033[0m | \033[1;32mNetwork Height:\033[0m \033[1;37m$network_height\033[0m | \033[1;32mBlocks Left:\033[0m \033[1;31m$blocks_left\033[0m"

  sleep 5
done

Example:

View the ports used node

ss -tulpn | grep 0gchaind

βš™οΈ Key Command

Create new wallet

0gchaind keys add wallet --eth

Recovery wallet

0gchaind keys add wallet --eth --recover

List all wallet

0gchaind keys list

Delete wallet

0gchaind keys delete wallet

Export wallet

0gchaind keys export wallet

Import wallet

0gchaind keys import wallet wallet.backup 

Check wallet balance

0gchaind q bank balances $(0gchaind keys show wallet -a) 

βš™οΈ Validator Commands

Create validator

0gchaind tx staking create-validator \
--amount 1000000ua0gi \
--chain-id=zgtendermint_16600-2 \
--pubkey $(0gchaind tendermint show-validator) \
--moniker "$NODE_MONIKER" \ #Validator name, displayed in explorers.
--identity "" \ #Use your KeyBase ID. If you don't have one, leave it empty.
--website "" \ #Your website
--details "" \ #Any details about your validator.
--commission-rate 0.1 \
--commission-max-rate 0.2 \
--commission-max-change-rate 0.01 \
--min-self-delegation 1 \
--from YOUR_WALLET \ #Wallet name, as specified during creation, or typically 'wallet'.
--gas-prices=0.25ua0gi  \
--gas-adjustment=1.5 \
--gas=auto \
-y

You can leave the text after # unchanged - it's a commented hint that won't affect validator creation.

β—½ Replace the following values with your own: WALLET - usually it's 'wallet', or your wallet's name. MONIKER - any convenient name for your validator, displayed in the explorer. IDENTITY - validator's avatar, displayed in the explorer. Create a KeyBase ID following the instructions or leave it empty, and it will default to a standard one. DETAILS - details about your validator, also displayed in the explorer.

Replace all necessary values indicated above with the $ sign to successfully create your validator. β—½ Example:

0gchaind tx staking create-validator \
--amount=1000000ua0gi \
--chain-id=zgtendermint_16600-2 \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker="Oliver" \ #Validator name, displayed in explorers.
--identity "" \        #Use your KeyBase ID. If you don't have one, leave it empty.
--details "Reliable validator for your network." \ #Any details about your validator.
--chain-id=zgtendermint_16600-2 \
--commission-rate=0.1 \
--commission-max-rate=0.2 \
--commission-max-change-rate=0.05 \
--min-self-delegation="1" \
--gas-prices=0.25ua0gi  \
--gas-adjustment=1.5 \
--gas=auto \
--from=wallet \ #Wallet name, as specified during creation, or typically 'wallet'.
-y

Update validator information

0gchaind tx staking edit-validator \
--commission-rate 0.1 \
--new-moniker "$MONIKER" \
--identity "" \
--details "$NEW_DETAILS" \
--from $WALLET \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.5 \
--gas auto \
-y

Validator details

0gchaind q staking validator $(0gchaind keys show wallet --bech val -a)

Jailing info

0gchaind q staking validator $(0gchaind keys show wallet --bech val -a) | grep -E "jailed"

If "true" - your validator is jailed // "false" - your validator is not jailed

Jail reason

0gchaind q slashing signing-info $(0gchaind tendermint show-validator)

Unjail command

0gchaind tx slashing unjail \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.5 \
--gas auto \
--from wallet \ # Or another wallet name
-y 

Information about delegation at your validator

0gchaind q staking validator $(0gchaind keys show wallet --bech val -a) | grep -E "tokens"

Active Validators list

0gchaind q staking validators -oj --limit=2000 | jq '.validators[] | select(.status=="BOND_STATUS_BONDED")' | jq -r '(.tokens|tonumber/pow(10; 6)|floor|tostring) + " 	 " + .description.moniker' | sort -gr | nl

Inactive Validator list

0gchaind q staking validators -oj --limit=2000 | jq '.validators[] | select(.status=="BOND_STATUS_UNBONDED" or .status=="BOND_STATUS_UNBONDING")' | jq -r '(.tokens|tonumber/pow(10; 6)|floor|tostring) + " \t " + .description.moniker' | sort -gr | nl 

Signing Info

0gchaind query slashing signing-info $(0gchaind tendermint show-validator) 

βš™οΈ Tokens Commands

Delegate to yourself

0gchaind tx staking delegate $(0gchaind keys show wallet --bech val -a) 1000000ua0gi --from wallet --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Delegate to another validator

0gchaind tx staking delegate <TO_VALOPER_ADDRESS> 1000000ua0gi --from $WALLET --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Redelegate your stake to other validator

0gchaind tx staking redelegate $VALOPER_ADDRESS <TO_VALOPER_ADDRESS> 1000000ua0gi --from $WALLET --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Unbond stake

0gchaind tx staking unbond $(0gchaind keys show $WALLET --bech val -a) 1000000ua0gi --from $WALLET --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Send tokens

0gchaind tx bank send $WALLET_ADDRESS <TO_WALLET_ADDRESS> 1000000ua0gi --gas-adjustment 1.5 --gas auto -y

Check wallet balance

0gchaind q bank balances $(0gchaind keys show wallet -a)

Transaction details

0gchaind query tx HASH_TX

Withdraw all rewards

0gchaind tx distribution withdraw-all-rewards --from $WALLET --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Withdraw rewards and commission from your validator

0gchaind tx distribution withdraw-rewards $VALOPER_ADDRESS --from $WALLET --commission --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

βš™οΈ Governance

List All Proposals

0gchaind query gov proposals

View proposal by ID

0gchaind query gov proposal ID

Vote "YES"

0gchaind tx gov vote PROPOSAL_ID yes --from wallet --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Vote "NO"

0gchaind tx gov vote PROPOSAL_ID no --from wallet --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Vote "NO_WITH_VETO"

0gchaind tx gov vote PROPOSAL_ID no_with_veto --from wallet --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Vote "ABSTAIN"

0gchaind tx gov vote PROPOSAL_ID abstain --from wallet --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto -y

Create new text proposal

0gchaind tx gov submit-proposal \
--title="Title" \ #Change Title
--description="Description" \
--deposit=1000000ua0gi \
--type="Text" \   #Change text proposal
--from=wallet \   #Change name wallet
--gas-adjustment=1.5 \
--gas auto \
-y 

βš™οΈ Utility

Set Custom Port


# Change CUSTOM_PORT to any other value, or leave it as is.
CUSTOM_PORT=27
sed -i.bak -e "s%:26658%:${CUSTOM_PORT}658%; s%:26657%:${CUSTOM_PORT}657%; s%:6060%:${CUSTOM_PORT}060%; s%:26656%:${CUSTOM_PORT}656%; s%:26660%:${CUSTOM_PORT}660%" $HOME/.0gchain/config/config.toml && sed -i.bak -e "s%:9090%:${CUSTOM_PORT}090%; s%:9091%:${CUSTOM_PORT}091%; s%:1317%:${CUSTOM_PORT}317%; s%:8545%:${CUSTOM_PORT}545%; s%:8546%:${CUSTOM_PORT}546%; s%:6065%:${CUSTOM_PORT}065%" $HOME/.0gchain/config/app.toml && sed -i.bak -e "s%:26657%:${CUSTOM_PORT}657%" $HOME/.0gchain/config/client.toml
sudo systemctl restart 0gchaind
journalctl -u 0gchaind -f -o cat

Set Indexer

sed -i 's|^indexer *=.*|indexer = "null"|' $HOME/.0gchain/config/config.toml

Update Pruning

sed -i.bak -e 's|^pruning *=.*|pruning = "custom"|; s|^pruning-keep-recent *=.*|pruning-keep-recent = "100"|; s|^pruning-keep-every *=.*|pruning-keep-every = "0"|; s|^pruning-interval *=.*|pruning-interval = "17"|' $HOME/.0gchain/config/app.toml

Reset node

0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book

Get denom info

0gchaind q bank denom-metadata -oj | jq

Get Node Peer

echo $(0gchaind tendermint show-node-id)'@'$(curl -s ifconfig.me)':'$(cat $HOME/.0gchain/config/config.toml | sed -n '/Address to listen for incoming connection/{n;p;}' | sed 's/.*://; s/".*//') 

Update server name

 sudo hostnamectl set-hostname server_name

How much SSD use node (currently)

du -sh $HOME/.0gchain/

How much RAM use node (currently)

ps -p $(pgrep 0gchaind) -o rss= | awk '{printf("The process uses memory:: %.2f MB\n", $1/1024)}'

How much CPU use node (currently)

ps -C 0gchaind -o %cpu --no-headers | awk '{print $1"% CPU"}'

Delete node

sudo systemctl stop 0gchaind
sudo systemctl disable 0gchaind
sudo rm -rf /etc/systemd/system/0gchaind.service
sudo rm $(which 0gchaind)
sudo rm -rf $HOME/.0gchain
sudo rm -rf $HOME/0g-chain

Last updated