Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mnugumanova
Last active April 28, 2022 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mnugumanova/e94823cebffbba044732bdb44f56e04b to your computer and use it in GitHub Desktop.
Save mnugumanova/e94823cebffbba044732bdb44f56e04b to your computer and use it in GitHub Desktop.
Script that withdraws commission and reward from the Regen network account and auto-delegates these tokens to the validator every 3 hours
echo "Enter your key password:"
read -s password
while true
do
echo "About to withdraw commission and reward"
echo "${password}" | xrncli tx distr withdraw-rewards <xrn:valoperAddress> --commission --from <key-name> --chain-id=$(cat ~/.xrnd/config/genesis.json | jq -r .chain_id) -y
sleep 60
amount=$(xrncli query account <xrn:address> --chain-id=$(cat ~/.xrnd/config/genesis.json | jq -r .chain_id) -o json --indent | jq -r '.value.coins[1].amount')
if [[ $amount > 0 && $amount != "null" ]]; then
echo "About to stake ${amount} uTREEs"
echo "${password}" | xrncli tx staking delegate xrn:valoper1c934d8gjup8e680ljmp3jxfqc5vwh28zd24t7m ${amount}tree --chain-id=$(cat ~/.xrnd/config/genesis.json | jq -r .chain_id) --trust-node --from <key-name> --gas-adjustment 1.1 -y
fi
sleep 10800
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment