# Useful commands

```bash
# Set Vars
MONIKER=<YOUR_MONIKER_NAME_GOES_HERE>
echo "export MONIKER=$MONIKER" >> $HOME/.bash_profile
echo "export OG_CHAIN_ID="zgtendermint_16600-1"" >> $HOME/.bash_profile
source $HOME/.bash_profile
```

### WALLET MANAGEMENT

{% hint style="info" %}
*Add Wallet Specify the value \<wallet> with your own wallet name*
{% endhint %}

```bash
#Add new wallet
0gchaind keys add wallet --eth

#Recover Wallet
0gchaind keys add wallet --recover --eth

#List Wallet
0gchaind keys list

#Delete Wallet
0gchaind keys delete wallet

#Check Wallet Balance
0gchaind q bank balances $(0gchaind keys show wallet -a)
```

### VALIDATOR MANAGEMENT

{% hint style="info" %}
*Please adjust , MONIKER , YOUR\_KEYBASE\_ID , YOUR\_DETAILS , YOUR\_WEBSITE\_URL*
{% endhint %}

```bash
#Create Validator
0gchaind tx staking create-validator \
--amount=10000000ua0gi \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker=$MONIKER \
--identity="YOUR_KEYBASE_ID" \
--details="YOUR_DETAILS" \
--website="YOUR_WEBSITE_URL" \
--chain-id=$OG_CHAIN_ID \
--commission-rate=0.10 \
--commission-max-rate=0.20 \
--commission-max-change-rate=0.01 \
--min-self-delegation=1000 \
--from=wallet \
--gas-adjustment=1.5 \
--gas="auto" \
--gas-prices=10ua0gi\ 
-y

#Edit Validator
0gchaind tx staking edit-validator \
--new-moniker="YOUR MONIKER" \
--identity="IDENTITY KEYBASE" \
--details="DETAILS VALIDATOR" \
--website="LINK WEBSITE" \
--chain-id=$OG_CHAIN_ID \
--from=wallet \
--gas-adjustment=1.5 \
--gas="auto" \
--gas-prices=10ua0gi\ 
-y

#Unjail Validator
0gchaind tx slashing unjail --from wallet --chain-id $OG_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 10ua0gi -y

#Check Jailed Reason
0gchaind query slashing signing-info $(0gchaind tendermint show-validator)
```

### TOKEN MANAGEMENT

```bash
#Withdraw Rewards
0gchaind tx distribution withdraw-all-rewards --from wallet --chain-id $OG_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 10ua0gi -y

#Withdraw Rewards with Comission
0gchaind tx distribution withdraw-rewards $(0gchaind keys show wallet --bech val -a) --commission --from wallet --chain-id $OG_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 10ua0gi -y

#Delegate Token to your own validator
0gchaind tx staking delegate $(0gchaind keys show wallet --bech val -a) 1000000ua0gi --from wallet --chain-id $OG_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 10ua0gi -y

#Delegate Token to other validator
0gchaind tx staking redelegate $(0gchaind keys show wallet --bech val -a) <TO_VALOPER_ADDRESS> 1000000ua0gi --from wallet --chain-id $OG_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 10ua0gi -y

#Unbond Token from your validator
0gchaind tx staking unbond $(0gchaind keys show wallet --bech val -a) 1000000ua0gi --from wallet --chain-id $OG_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 10ua0gi -y

#Send Token to another wallet
0gchaind tx bank send wallet <TO_WALLET_ADDRESS> 1000000ua0gi --from wallet --chain-id $OG_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 10ua0gi -y
```

### GOVERNANCE

```bash
#Vote, You can change the value of yes to no,abstain,nowithveto
0gchaind tx gov vote 1 yes --from wallet --chain-id $OG_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 10ua0gi -y

#List all proposals
0gchaind query gov proposals

#Create new text proposal
0gchaind tx gov submit-proposal \
--title="Title" \
--description="Description" \
--deposit=100000000ua0gi \
--type="Text" \
--from=wallet \
--gas-adjustment 1.5 \
--gas "auto" \
--gas-prices=10ua0gi\ 
-y 
```

### SERVICES MANAGEMENT

```bash
# Reload Service
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
```

### UTILITY

```bash
#Set Indexer NULL / KV
sed -i 's|^indexer *=.*|indexer = "null"|' $HOME/.0gchain/config/config.toml

#Get Validator info
0gchaind status 2>&1 | jq .ValidatorInfo

#Get denom info
0gchaind q bank denom-metadata -oj | jq

#Get sync status
0gchaind status 2>&1 | jq .SyncInfo.catching_up

#Get latest height
0gchaind status 2>&1 | jq .SyncInfo.latest_block_height

#Reset Node
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book
```

### DELETE NODE

{% hint style="warning" %} <mark style="color:red;">**WARNING! Use this command wisely Backup your key first it will remove node from your system**</mark>
{% endhint %}

```bash
sudo systemctl stop 0gchaind && sudo systemctl disable 0gchaind && sudo rm /etc/systemd/system/0gchaind.service && sudo systemctl daemon-reload && sudo rm -rf $(which 0gchaind) && rm -rf $HOME/.0gchain && rm -rf $HOME/go/bin/0gchaind
```
