# CLI Cheatsheet

<figure><img src="https://explorer.indonode.net/logos/mantra.jpg" alt="" width="188"><figcaption></figcaption></figure>

### Key Management

Add new key

```
mantrachaind keys add wallet
```

Recover existing key

```
mantrachaind keys add wallet --recover
```

List All key

```
mantrachaind keys list
```

Delete key

```
mantrachaind keys delete wallet
```

Export Key (save to wallet.backup)

```
mantrachaind keys export wallet
```

Import key

```
mantrachaind keys import wallet wallet.backup
```

Query Wallet Balance

```
mantrachaind q bank balances $(mantrachaind keys show wallet -a)
```

### Validator Management

Create Validator

```sh
mantrachaind tx staking create-validator \
  --amount "1000000uaum" \
  --pubkey $(mantrachaind tendermint show-validator) \
  --moniker "MONIKER" \
  --identity "KEYBASE_ID" \
  --details "YOUR DETAILS" \
  --website "YOUR WEBSITE" \
  --chain-id mantrachain-testnet-1 \
  --commission-rate "0.05" \
  --commission-max-rate "0.20" \
  --commission-max-change-rate "0.01" \
  --min-self-delegation "1" \
  --fees 50uaum \
  --gas "auto" \
  --gas-adjustment "1.5" \
  --from wallet \
  -y

```

Edit Validator

```sh
mantrachaind tx staking edit-validator \
--new-moniker="MONIKER" \
--identity="YOUR_KEYBASE_ID" \
--details="YOUR_DETAILS" \
--website="YOUR_WEBSITE_URL" \
--chain-id mantrachain-testnet-1 \
--commission-rate=0.05 \
--fees 50uaum \
--gas="auto" \
--gas-adjustment="1.5" \
--from wallet \
-y
```

Unjail Validator

```sh
mantrachaind tx slashing unjail --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

Signing Info

```sh
mantrachaind query slashing signing-info $(mantrachaind tendermint show-validator) 
```

List all active validators

```sh
mantrachaind 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

```sh
mantrachaind q staking validators -oj --limit=3000 | 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 
```

View validators details

```
mantrachaind q staking validator $(mantrachaind keys show wallet --bech val -a) 
```

### Token Management

Withdraw rewards from all validators

```sh
mantrachaind tx distribution withdraw-all-rewards --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

Withdraw comission and rewards from your validator

```sh
mantrachaind tx distribution withdraw-rewards $(mantrachaind keys show wallet --bech val -a) --commission --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

Delegate to your validator

```sh
mantrachaind tx staking delegate $(mantrachaind keys show wallet --bech val -a) 1000000uaum --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

Delegate to other

```sh
c4ed tx staking delegate TO_VALOPER_ADDRESS 1000000uaum --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

Redelegate your stake to other validators

```sh
mantrachaind tx staking redelegate $(mantrachaind keys show wallet --bech val -a) TO_VALOPER_ADDRESS 1000000uaum --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

Unbond stake

```sh
mantrachaind tx staking unbond $(mantrachaind keys show wallet --bech val -a) 1000000uaum --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

Send tokens

```sh
mantrachaind tx bank send wallet TO_WALLET_ADDRESS 1000000uaum --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

### Governance

List all proposals

<pre class="language-sh"><code class="lang-sh"><strong>mantrachaind query gov proposals
</strong></code></pre>

Vote **YES / NO / ABSTAIN / NO\_WITH\_VETO**

```sh
mantrachaind tx gov vote 1 yes --from wallet --chain-id mantrachain-testnet-1 --fees 50uaum --gas-adjustment 1.5 --gas "auto" -y 
```

Create new text proposal

```sh
mantrachaind tx gov submit-proposal \
--title="Title" \
--description="Description" \
--deposit=100000000uaum \
--type="Text" \
--from=wallet \
--fees 50uaum\ 
--gas-adjustment 1.5 \
--gas "auto" \
-y 
```

### Utility

Set Indexer **NULL / KV**

```sh
sed -i 's|^indexer *=.*|indexer = "null"|' $HOME/.mantrachain /config/config.toml
```

Set Custom Port

```sh
CUSTOM_PORT=13
sed -i.bak -e "s%^proxy_app = \"tcp://127.0.0.1:26658\"%proxy_app = \"tcp://127.0.0.1:${CUSTOM_PORT}658\"%; s%^laddr = \"tcp://127.0.0.1:26657\"%laddr = \"tcp://127.0.0.1:${CUSTOM_PORT}657\"%; s%^pprof_laddr = \"localhost:6060\"%pprof_laddr = \"localhost:${CUSTOM_PORT}060\"%; s%^laddr = \"tcp://0.0.0.0:26656\"%laddr = \"tcp://0.0.0.0:${CUSTOM_PORT}656\"%; s%^prometheus_listen_addr = \":26660\"%prometheus_listen_addr = \":${CUSTOM_PORT}660\"%" $HOME/.mantrachain/config/config.toml
sed -i.bak -e "s%^address = \"tcp://0.0.0.0:1317\"%address = \"tcp://0.0.0.0:${CUSTOM_PORT}317\"%; s%^address = \":8080\"%address = \":${CUSTOM_PORT}080\"%; s%^address = \"0.0.0.0:9090\"%address = \"0.0.0.0:${CUSTOM_PORT}090\"%; s%^address = \"0.0.0.0:9091\"%address = \"0.0.0.0:${CUSTOM_PORT}091\"%; s%^address = \"0.0.0.0:8545\"%address = \"0.0.0.0:${CUSTOM_PORT}545\"%; s%^ws-address = \"0.0.0.0:8546\"%ws-address = \"0.0.0.0:${CUSTOM_PORT}546\"%" $HOME/.mantrachain/config/app.toml
```

Get Validator info

```sh
mantrachaind status 2>&1 | jq .ValidatorInfo
```

Get denom info

```sh
mantrachaind q bank denom-metadata -oj | jq
```

Get sync status

```sh
mantrachaind status 2>&1 | jq .SyncInfo.catching_up
```

Get latest height

```sh
mantrachaind status 2>&1 | jq .SyncInfo.latest_block_height
```

Reset Node

```sh
mantrachaind tendermint unsafe-reset-all --home $HOME/.mantrachain --keep-addr-book
```

Delete Node

```sh
sudo systemctl stop mantrachaind && sudo systemctl disable mantrachaind && sudo rm /etc/systemd/system/mantrachaind.service && sudo systemctl daemon-reload && rm -rf $HOME/.mantrachain && sudo rm -rf $(which mantrachaind) 
```

### Services Management

```sh
# Reload Service
sudo systemctl daemon-reload

# Enable Service
sudo systemctl enable mantrachaind

# Disable Service
sudo systemctl disable mantrachaind

# Start Service
sudo systemctl start mantrachaind

# Stop Service
sudo systemctl stop mantrachaind

# Restart Service
sudo systemctl restart mantrachaind

# Check Service Status
sudo systemctl status mantrachaind

# Check Service Logs
sudo journalctl -u mantrachaind -f --no-hostname -o cat
```
