Useful commands

Information

# check the blocks
0gchaind status 2>&1 | jq ."SyncInfo"."latest_block_height"

# check the logs
journalctl -u 0gchaind -f -o cat

# check status
curl localhost:26657/status

# check balance
0gchaind q bank balances <address>

# check the validator pubkey
0gchaind tendermint show-validator

# check the validator
0gchaind query staking validator <valoper_address>
0gchaind query staking validators --limit 1000000 -o json | jq '.validators[] | select(.description.moniker=="<name_moniker>")' | jq

# check TX_HASH information
0gchaind query tx <TX_HASH>

# network parameters
0gchaind q staking params
0gchaind q slashing params

# check how many blocks are missed by the validator and from which block is active
0gchaind q slashing signing-info $(0gchaind tendermint show-validator)

# find out the validator creation transaction (replace your valoper_address)
0gchaind query txs --events='create_validator.validator=<your_valoper_address>' -o=json | jq .txs[0].txhash -r

# view active set
0gchaind q staking validators -o json --limit=1000 \
| jq '.validators[] | select(.status=="BOND_STATUS_BONDED")' \
| jq -r '.tokens + " - " + .description.moniker' \
| sort -gr | nl

# view inactive set
0gchaind q staking validators -o json --limit=1000 \
| jq '.validators[] | select(.status=="BOND_STATUS_UNBONDED")' \
| jq -r '.tokens + " - " + .description.moniker' \
| sort -gr | nl

Transactions

# collect rewards from all validators to whom delegated (no commission)
0gchaind tx distribution withdraw-all-rewards --from <name_wallet> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

# collect rewards from a separate validator or rewards + commission from your own validator
0gchaind tx distribution withdraw-rewards <valoper_address> --from <name_wallet> --commission --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

# delegate yourself into the steak some more (so 1 coin is sent)
0gchaind tx staking delegate <valoper_address> 1000000unls --from <name_wallet> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

# redelegation to another validator
0gchaind tx staking redelegate <src-validator-addr> <dst-validator-addr> 1000000unls --from <name_wallet> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

# unbond 
0gchaind tx staking unbond <addr_valoper> 1000000uqsr --from <name_wallet> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

# send coins to another address
0gchaind tx bank send <name_wallet> <address> 1000000uqsr --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

# get out of jail
0gchaind tx slashing unjail --from <name_wallet> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

Working with wallets

# display wallet list
0gchaind keys list

# show account key
0gchaind keys show <name_wallet> --bech acc

# show validator key
0gchaind keys show <name_wallet> --bech val

# show consensus key
0gchaind keys show <name_wallet> --bech cons

# show all supported addresses
0gchaind debug addr <wallet_addr>

# show private key
0gchaind keys export <name_wallet> --unarmored-hex --unsafe

# requesting an account
0gchaind q auth account $(nolusd keys show <name_wallet> -a) -o text

# delete wallet
0gchaind keys delete <name_wallet>

Delete node

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

Governance

# list of proposals
0gchaind q gov proposals

# to see the result of the vote
0gchaind q gov proposals --voter <ADDRESS>

# vote in favor of the proposal
0gchaind tx gov vote 1 yes --from <name_wallet> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

# make a deposit on the proposal
0gchaind tx gov deposit 1 1000000uqsr --from <name_wallet> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

# create a proposal
0gchaind tx gov submit-proposal --title="Randomly reward" --description="Reward 10 testnet participants who completed more than 3 tasks" --type="Text" --deposit="11000000uqsr" --from=<name_wallet> --chain-id zgtendermint_16600-2 --gas=auto --gas-adjustment=1.6 -y 

Peers and RPC

FOLDER=.nolus

# find out your peer
PORTR=$(grep -A 3 "\[p2p\]" ~/$FOLDER/config/config.toml | egrep -o ":[0-9]+") && \
echo $(quasarnoded tendermint show-node-id)@$(curl ifconfig.me)$PORTR

# get the RPC port
echo -e "\033[0;32m$(grep -A 3 "\[rpc\]" ~/$FOLDER/config/config.toml | egrep -o ":[0-9]+")\033[0m"

# check the number of peers
PORT=
curl -s http://localhost:$PORT/net_info | jq -r '.result.peers[] | "\(.node_info.id)@\(.remote_ip):\(.node_info.listen_addr | split(":")[2])"' | wc -l

# moniker list of connected peers
curl -s http://localhost:$PORT/net_info | jq '.result.peers[].node_info.moniker'

# Check prevotes/precommits. Useful for updates
curl -s localhost:$PORT/consensus_state | jq '.result.round_state.height_vote_set[0].prevotes_bit_array' && \
curl -s localhost:$PORT/consensus_state | jq '.result.round_state.height_vote_set[0].precommits_bit_array'

# check prevote of your validator
curl -s localhost:$PORT/consensus_state -s | grep $(curl -s localhost:26657/status | jq -r .result.validator_info.address[:12])

Last updated