> For the complete documentation index, see [llms.txt](https://service.block-pro.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://service.block-pro.net/testnet/cardchain/useful-commands.md).

# Useful commands

## Information

```
# check the blocks
nolusd status 2>&1 | jq ."SyncInfo"."latest_block_height"

# check the logs
journalctl -u nolusd -f -o cat

# check status
curl localhost:26657/status

# check balance
nolusd q bank balances <address>

# check the validator pubkey
nolusd tendermint show-validator

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

# check TX_HASH information
nolusd query tx <TX_HASH>

# network parameters
nolusd q staking params
nolusd q slashing params

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

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

# view active set
nolusd 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
nolusd 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)
nolusd tx distribution withdraw-all-rewards --from <name_wallet> --fees 5000unls -y

# collect rewards from a separate validator or rewards + commission from your own validator
nolusd tx distribution withdraw-rewards <valoper_address> --from <name_wallet> --fees 5000unls --commission -y

# delegate yourself into the steak some more (so 1 coin is sent)
nolusd tx staking delegate <valoper_address> 1000000unls --from <name_wallet> --fees 5000unls -y

# redelegation to another validator
nolusd tx staking redelegate <src-validator-addr> <dst-validator-addr> 1000000unls --from <name_wallet> --fees 5000unls -y

# unbond 
nolusd tx staking unbond <addr_valoper> 1000000unls --from <name_wallet> --fees 5000unls -y

# send coins to another address
nolusd tx bank send <name_wallet> <address> 1000000unls --fees 5000unls -y

# get out of jail
nolusd tx slashing unjail --from <name_wallet> --fees 5000unls -y
```

## Working with wallets

```
# display wallet list
nolusd keys list

# show account key
nolusd keys show <name_wallet> --bech acc

# show validator key
nolusd keys show <name_wallet> --bech val

# show consensus key
nolusd keys show <name_wallet> --bech cons

# show all supported addresses
nolusd debug addr <wallet_addr>

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

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

# delete wallet
nolusd keys delete <name_wallet>
```

## Delete node

```
systemctl stop nolusd && \
systemctl disable nolusd && \
rm /etc/systemd/system/nolusd.service && \
systemctl daemon-reload && \
cd $HOME && \
rm -rf .nolus nolus-core && \
rm -rf $(which nolusd)
```

## Governance

```
# list of proposals
nolusd q gov proposals

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

# vote in favor of the proposal
nolusd tx gov vote 1 yes --from <name_wallet> --fees 555unls

# make a deposit on the proposal
nolusd tx gov deposit 1 1000000unls --from <name_wallet> --fees 555unls

# create a proposal
nolusd tx gov submit-proposal --title="Randomly reward" --description="Reward 10 testnet participants who completed more than 3 tasks" --type="Text" --deposit="11000000grain" --from=<name_wallet> --fees 500grain
```

## Peers and RPC

```
FOLDER=.nolus

# find out your peer
PORTR=$(grep -A 3 "\[p2p\]" ~/$FOLDER/config/config.toml | egrep -o ":[0-9]+") && \
echo $(nolusd 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])
```
