Skip to content

Instantly share code, notes, and snippets.

@delef
Created July 25, 2021 09:32
Show Gist options
  • Save delef/8660a0fbe87ba5bdb9d13789825dfa06 to your computer and use it in GitHub Desktop.
Save delef/8660a0fbe87ba5bdb9d13789825dfa06 to your computer and use it in GitHub Desktop.
#!/bin/bash
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
DELEGATOR='rizon1szrdljj0d30lscumhezyn3a678yjugsu6xjrx6'
VALIDATOR='rizonvaloper1szrdljj0d30lscumhezyn3a678yjugsufzszy2'
PASWD='PASS'
DELAY=600 #in secs
WALLET_NAME=delef
COIN=uatolo
FEE=1000
BALANCE=0;
getBalance () {
BALANCE=$(rizond query bank balances ${1} -o json | jq -r '.balances[].amount');
}
for (( ;; )); do
getBalance ${DELEGATOR}
echo -e "balance: ${GREEN}${BALANCE}${NC} ${COIN}\nclaim rewards\n"
printf "${PASWD}\n" | rizond tx distribution withdraw-rewards ${VALIDATOR} --commission --from ${WALLET_NAME} --fees ${FEE}${COIN} -y
for (( timer=10; timer>0; timer-- ))
do
printf "* sleep for ${RED}%02d${NC} sec\r" $timer
sleep 1
done
getBalance ${DELEGATOR}
echo -e "balance: ${GREEN}${BALANCE}${NC} ${COIN}\nstake ALL\n"
DELEGATE_BALANCE=$((BALANCE-FEE))
printf "${PASWD}\n" | rizond tx staking delegate ${VALIDATOR} ${DELEGATE_BALANCE}${COIN} --from ${WALLET_NAME} --fees=${FEE}${COIN} -y
for (( timer=${DELAY}; timer>0; timer-- ))
do
printf "* sleep for ${RED}%02d${NC} sec\r" $timer
sleep 1
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment