Skip to content

Instantly share code, notes, and snippets.

@atsiarenia
Created July 23, 2021 10:55
Show Gist options
  • Save atsiarenia/6bab84aa815c4156cc462f67e9d2eff8 to your computer and use it in GitHub Desktop.
Save atsiarenia/6bab84aa815c4156cc462f67e9d2eff8 to your computer and use it in GitHub Desktop.
Claiming, getting reward from delegation and delegating rewards for Rizon
#!/bin/bash
GREEN_COLOR='\033[0;32m'
RED_COLOR='\033[0;31m'
WITHOU_COLOR='\033[0m'
DELEGATOR_ADDRESS='rizon1_BLA_BLA'
VALIDATOR_ADDRESS='rizonvaloper1_BLA_BLA'
PWD='YOUR_PASSWORD'
DELAY=3600 #in secs - how often restart the script
ACC_NAME=YOU_WALLET_WITHOUT_QUOTES #example: = ACC_NAME=wallet_qwwq_54
NODE=http://localhost:26657 #change it only if you use another rpc port of your node
for (( ;; )); do
echo -e "Get reward from Delegation"
echo -e "${PWD}\ny\n" | rizond tx distribution withdraw-all-rewards --from ${ACC_NAME} --fees 20uatolo --chain-id groot-07 --yes
for (( timer=10; timer>0; timer-- ))
do
printf "* sleep for ${RED_COLOR}%02d${WITHOUT_COLOR} sec\r" $timer
sleep 1
done
BAL=$(rizond query bank balances ${DELEGATOR_ADDRESS} --node ${NODE});
# BAL=$(($BAL -100000))
echo -e "BALANCE: ${GREEN_COLOR}${BAL}${WITHOU_COLOR} uatolo\n"
echo -e "Claim rewards\n"
echo -e "${PWD}\n${PWD}\n" | rizond tx distribution withdraw-rewards ${VALIDATOR_ADDRESS} --chain-id groot-07 --from ${ACC_NAME} --node ${NODE} --commission -y --fees 5000uatolo
for (( timer=10; timer>0; timer-- ))
do
printf "* sleep for ${RED_COLOR}%02d${WITHOU_COLOR} sec\r" $timer
sleep 1
done
BAL=$(rizond query bank balances ${DELEGATOR_ADDRESS} --node ${NODE} -o json | jq -r '.balances | .[].amount');
BAL=$(($BAL -100000))
echo -e "BALANCE: ${GREEN_COLOR}${BAL}${WITHOU_COLOR} uatolo\n"
echo -e "Stake ALL 11111\n"
echo -e "${PWD}\n${PWD}\n" | rizond tx staking delegate ${VALIDATOR_ADDRESS} ${BAL}uatolo --chain-id groot-07 --from ${ACC_NAME} --node ${NODE} -y --fees 5000uatolo
for (( timer=${DELAY}; timer>0; timer-- ))
do
printf "* sleep for ${RED_COLOR}%02d${WITHOU_COLOR} sec\r" $timer
sleep 1
done
done
@atsiarenia
Copy link
Author

  1. Set You data for DELEGATOR_ADDRESS and etc
  2. Give the permissions to this file:
    chmod +x auto_stake_rizon.sh
  3. Open screen session:
    screen -S magic_stake
  4. Run script
    bash auto_stake_rizon.sh

@atsiarenia
Copy link
Author

If You have some problems with the script try to uncomment String 22 - # BAL=$(($BAL -100000))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment