# Useful commands

```bash
# Set Vars
MONIKER=<YOUR_MONIKER_NAME_GOES_HERE>
echo "export MONIKER=$MONIKER" >> $HOME/.bash_profile
echo "export DHEALTH_CHAIN_ID="dhealth"" >> $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
dhealthd keys add wallet

#Recover Wallet
dhealthd keys add wallet --recover

#List Wallet
dhealthd keys list

#Delete Wallet
dhealthd keys delete wallet

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

### VALIDATOR MANAGEMENT

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

```bash
#Create Validator
dhealthd tx staking create-validator \
--amount=10000000udhp \
--pubkey=$(dhealthd tendermint show-validator) \
--moniker=$MONIKER \
--identity="YOUR_KEYBASE_ID" \
--details="YOUR_DETAILS" \
--website="YOUR_WEBSITE_URL" \
--chain-id=$DHEALTH_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=1udhp\ 
-y

#Edit Validator
dhealthd tx staking edit-validator \
--new-moniker="YOUR MONIKER" \
--identity="IDENTITY KEYBASE" \
--details="DETAILS VALIDATOR" \
--website="LINK WEBSITE" \
--chain-id=$DHEALTH_CHAIN_ID \
--from=wallet \
--gas-adjustment=1.5 \
--gas="auto" \
--gas-prices=1udhp\ 
-y

#Unjail Validator
dhealthd tx slashing unjail --from wallet --chain-id $DHEALTH_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 1udhp -y

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

### TOKEN MANAGEMENT

```bash
#Withdraw Rewards
dhealthd tx distribution withdraw-all-rewards --from wallet --chain-id $DHEALTH_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 1udhp -y

#Withdraw Rewards with Comission
dhealthd tx distribution withdraw-rewards $(dhealthd keys show wallet --bech val -a) --commission --from wallet --chain-id $DHEALTH_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 1udhp -y

#Delegate Token to your own validator
dhealthd tx staking delegate $(dhealthd keys show wallet --bech val -a) 1000000udhp --from wallet --chain-id $DHEALTH_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 1udhp -y

#Delegate Token to other validator
dhealthd tx staking redelegate $(dhealthd keys show wallet --bech val -a) <TO_VALOPER_ADDRESS> 1000000udhp --from wallet --chain-id $DHEALTH_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 1udhp -y

#Unbond Token from your validator
dhealthd tx staking unbond $(dhealthd keys show wallet --bech val -a) 1000000udhp --from wallet --chain-id $DHEALTH_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 1udhp -y

#Send Token to another wallet
dhealthd tx bank send wallet <TO_WALLET_ADDRESS> 1000000udhp --from wallet --chain-id $DHEALTH_CHAIN_ID --gas-adjustment 1.5 --gas auto --gas-prices 1udhp -y
```

### GOVERNANCE

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

#List all proposals
dhealthd query gov proposals

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

### SERVICES MANAGEMENT

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

# Enable Service
sudo systemctl enable dhealthd

# Disable Service
sudo systemctl disable dhealthd

# Start Service
sudo systemctl start dhealthd

# Stop Service
sudo systemctl stop dhealthd

# Restart Service
sudo systemctl restart dhealthd

# Check Service Status
sudo systemctl status dhealthd

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

### UTILITY

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

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

#Get denom info
dhealthd q bank denom-metadata -oj | jq

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

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

#Reset Node
dhealthd tendermint unsafe-reset-all --home $HOME/.dhealth --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 dhealthd && sudo systemctl disable dhealthd && sudo rm /etc/systemd/system/dhealthd.service && sudo systemctl daemon-reload && sudo rm -rf $(which dhealthd) && rm -rf $HOME/.dhealth && rm -rf $HOME/go/bin/dhealthd && rm -rf $HOME/dhealth
```
