> For the complete documentation index, see [llms.txt](https://docs.nodecattel.xyz/node-guides/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nodecattel.xyz/node-guides/quick-start/zerogravity-0g/useful-commands.md).

# Useful commands

List of useful command for ZeroGravity (0G) credit to Kenz|DragonVN

{% tabs %}
{% tab title="Wallet Management" %}

#### **SET $WALLET\_NAME**

```bash
export WALLET_NAME=wallet
```

#### **ADD NEW KEY**

```bash
0gchaind keys add $WALLET_NAME --eth
```

**RECOVER EXISTING KEY**

```bash
0gchaind keys add $WALLET_NAME --eth --recover
```

**LIST ALL KEYS**

```bash
0gchaind keys list
```

**DELETE KEY**

```bash
0gchaind keys delete <key_name>
```

**SHOW 0x ADDRESS OF A WALLET**

```bash
echo "0x$(0gchaind debug addr $(0gchaind keys show $WALLET_NAME -a) | grep hex | awk '{print $3}')"
```

**EXPORT PRIVATE KEY OF AN 0x ADDRESS**

```bash
0gchaind keys unsafe-export-eth-key $WALLET_NAME
```

**QUERY WALLET BALANCE**

```bash
0gchaind q bank balances $(0gchaind keys show $WALLET_NAME -a)
```

{% endtab %}

{% tab title="Validator Management" %}
Please make sure you adjust moniker, identity, details and website to match your values.

For each field that you do not have you may delete the whole line of the command.

Indentity is where you can display your node's logo. Please setup with [Keybase.io](https://keybase.io/)

**CREATE NEW VALIDATOR**

```bash
0gchaind tx staking create-validator \
--amount 1000000ua0gi \
--pubkey $(0gchaind tendermint show-validator) \
--moniker "YOUR_MONIKER_NAME" \
--identity "YOUR_KEYBASE_ID" \
--details "YOUR_DETAILS" \
--website "YOUR_WEBSITE_URL" \
--chain-id zgtendermint_16600-2 \
--commission-rate 0.05 \
--commission-max-rate 0.20 \
--commission-max-change-rate 0.05 \
--min-self-delegation 1 \
--from $WALLET_NAME \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**EDIT EXISTING VALIDATOR**

```bash
0gchaind tx staking edit-validator \
--new-moniker "YOUR_NEW_MONIKER_NAME" \
--identity "YOUR_KEYBASE_ID" \
--details "YOUR_DETAILS" \
--website "YOUR_WEBSITE_URL" \
--chain-id zgtendermint_16600-2 \
--commission-rate 0.05 \
--from $WALLET_NAME \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**UNJAIL VALIDATOR**

```bash
0gchaind tx slashing unjail \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**JAIL REASON**

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

**LIST ALL ACTIVE VALIDATORS**

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

**LIST ALL INACTIVE VALIDATORS**

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

**VIEW YOUR VALIDATOR DETAILS**

```bash
0gchaind q staking validator $(0gchaind keys show $WALLET_NAME --bech val -a)
```

{% endtab %}

{% tab title="Token Management" %}
**WITHDRAW REWARDS FROM ALL VALIDATORS**

```bash
0gchaind tx distribution withdraw-all-rewards \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**WITHDRAW COMMISSION AND REWARDS FROM YOUR VALIDATOR**

```bash
0gchaind tx distribution withdraw-rewards $(0gchaind keys show $WALLET_NAME --bech val -a) \
--commission \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**DELEGATE TOKENS TO YOURSELF**

```bash
0gchaind tx staking delegate $(0gchaind keys show $WALLET_NAME --bech val -a) 1000000ua0gi \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**DELEGATE TOKENS TO VALIDATOR**

```bash
0gchaind tx staking delegate <TO_VALOPER_ADDRESS> 1000000ua0gi \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**REDELEGATE TOKENS TO ANOTHER VALIDATOR**

```bash
0gchaind tx staking redelegate $(0gchaind keys show $WALLET_NAME --bech val -a) <TO_VALOPER_ADDRESS> 1000000ua0gi \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**UNBOND TOKENS FROM YOUR VALIDATOR**

```bash
0gchaind tx staking unbond $(0gchaind keys show $WALLET_NAME --bech val -a) 1000000ua0gi \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

**SEND TOKENS TO THE WALLET**

```bash
0gchaind tx bank send $WALLET_NAME <TO_WALLET_ADDRESS> 1000000ua0gi \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
```

{% endtab %}
{% endtabs %}
