Skip to content

Instantly share code, notes, and snippets.

@MBGBuzzer
Forked from sl-he/cosmos.sh
Created May 21, 2020 14:28
Show Gist options
  • Save MBGBuzzer/2e24bb4694dfe2537d43cee4634b6741 to your computer and use it in GitHub Desktop.
Save MBGBuzzer/2e24bb4694dfe2537d43cee4634b6741 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Using:
# cosmos.sh PASS VALIDATOR DELEGATOR WALLET_NAME NETWORK_NAME COIN DENOMINATION
CLI="/root/go/bin/kvcli"
wallet_pass=$1
validator=$2
delegator=$3
wallet_name=$4
network=$5
coin=$6
denomination=$7
echo -en "\033[33;7mBEFORE\033[0m\n"
$CLI q staking validator $validator --trust-node
reward=$($CLI q distribution rewards $delegator $validator | sed -n 2p | cut -d "\"" -f 2 | cut -d "." -f 1)
echo -en "\033[33;7mRewards:\033[0m\n"
echo $reward / $denomination | bc -l
sleep 7
echo -e "$wallet_pass\n$wallet_pass\n" | $CLI tx distribution withdraw-rewards --commission $validator --from $wallet_name --chain-id $network --yes
sleep 8
balance=$($CLI q account $delegator | sed -n 5p | cut -d "\"" -f 2)
echo -en "\033[33;7mBalance:\033[0m\n"
echo $balance / $denomination | bc -l
echo -e "$wallet_pass\n$wallet_pass\n" | $CLI tx staking delegate $validator $balance$coin --from $wallet_name --chain-id $network --yes
sleep 10
echo -en "\033[33;7mAFTER\033[0m\n"
$CLI q staking validator $validator --trust-node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment