Skip to main content

CLI Cheatsheet

Chain ID: zgtendermint_16600-2 | Current Node Version: 0.3.1.alpha.1

This cheatsheet collects commonly used CLI commands for node operators to easily copy and paste. A few conventions we follow:

  • Capitalized words indicate placeholders
  • Always use our own [NODERS]TEAM RPC endpoints
  • Always specify --chain-id and --node flags even when they are unnecessary
  • Query CLI command always uses --output json flag and pipes result through jq

Wallet generate and recover

Add new key

0gchaind keys add KEY

Recover key (via existing mnemonic)

0gchaind keys add KEY --recover

List all keys

0gchaind keys list

Delete key

0gchaind keys delete KEY

Wallet

Wallet balance

0gchaind q bank balances $(0gchaind keys show KEY -a) --node https://og-t-rpc.noders.services:443

Send

0gchaind tx bank send YOUR_KEY RECEIVER_ADDRESS 1000000ua0gi \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Withdraw rewards from all validators

0gchaind tx distribution withdraw-all-rewards \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Withdraw Rewards including Commission

0gchaind tx distribution withdraw-rewards VALIDATOR_ADRESS \
--commission \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Delegate tokens to yourself

0gchaind tx staking delegate $(0gchaind keys show KEY --bech val -a) 1000000ua0gi \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Delegate tokens to validator

0gchaind tx staking delegate VALIDATOR_ADDRESS 1000000ua0gi \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Redelegate tokens to another validator

0gchaind tx staking redelegate $(0gchaind keys show KEY --bech val -a) VALIDATOR_ADDRESS 1000000ua0gi \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Unbond tokens from your validator

0gchaind tx staking unbond $(0gchaind keys show KEY --bech val -a) ua0gi \
--chain-id andromeda-1 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Governance

List of all proposals

0gchaind query gov proposals --node https://og-t-rpc.noders.services:443

Check vote

0gchaind query gov proposal PROPOSAL_NUMBER \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--output json | jq

Vote

Vote options:

  • yes
  • no
  • no_with_veto
  • abstain
0gchaind tx gov vote PROPOSAL_NUMBER VOTE_OPTION \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Validator management

Create Validator

note

We use example filed values instead of capitalized dummy words for demo purpose in this command. Please make sure to adjust accordingly for your use.

0gchaind tx staking create-validator \
--amount 1000000ua0gi \
--commission-max-change-rate "0.05" \
--commission-max-rate "0.10" \
--commission-rate "0.05" \
--min-self-delegation "1" \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker '[NODERS]TEAM SERVICE' \
--website "https://noders.team" \
--identity "220491ADDD660741" \
--details "Trusted blockchain validator and web3 developer team" \
--security-contact="office@noders.team" \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Edit validator

0gchaind tx staking edit-validator \
--new-moniker "YOUR_MONIKER_NAME" \
--identity "YOUR_KEYBASE_ID" \
--details "YOUR_DETAILS" \
--website "YOUR_WEBSITE_URL" \
--chain-id zgtendermint_16600-2 \
--commission-rate 0.05 \
--from KEY \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \

Unjail

0gchaind tx slashing unjail \
--chain-id zgtendermint_16600-2 \
--node https://og-t-rpc.noders.services:443 --fees 3000ua0gi \
--from KEY

Jail reason

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

Validator details

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

Maintenance

Get validator info

0gchaind status 2>&1 | jq .ValidatorInfo

Get sync info

0gchaind status 2>&1 | jq .SyncInfo

Get node peer

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

Check if validator key is correct

[[ $(0gchaind q staking validator $(0gchaind keys show KEY --bech val -a) -oj | jq -r .consensus_pubkey.key) = $(0gchaind status | jq -r .ValidatorInfo.PubKey.value) ]] && echo -e "\n\e[1m\e[32mTrue\e[0m\n" || echo -e "\n\e[1m\e[31mFalse\e[0m\n"

Get live peers

curl -sS https://og-t-rpc.noders.services:443/net_info | jq -r '.result.peers[] | "\(.node_info.id)@\(.remote_ip):\(.node_info.listen_addr)"' | awk -F ':' '{print $1":"$(NF)}'

Set minimum gas price

sed -i -e "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0.001ua0gi\"/" ~/.0gchain/config/app.toml

###Enable prometheus

sed -i -e "s/prometheus = false/prometheus = true/" ~/.0gchain/config/config.toml

Reset chain data

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

Service Management

Reload service configuration

sudo systemctl daemon-reload

Enable service

sudo systemctl enable 0gchaind

Disable service

sudo systemctl disable 0gchaind

Start service

sudo systemctl start 0gchaind

Stop service

sudo systemctl stop 0gchaind

Restart service

sudo systemctl restart 0gchaind

Check service status

sudo systemctl status 0gchaind

Check service logs

sudo journalctl -u 0gchaind -f --no-hostname -o cat

Remove node

cd $HOME
sudo systemctl stop 0gchaind
sudo systemctl disable 0gchaind
sudo rm /etc/systemd/system/
sudo systemctl daemon-reload
rm -f $(which 0gchaind)
rm -rf ~/.0gchain
rm -rf $HOME/0g-chain