Last active
May 5, 2022 09:56
-
-
Save jasny/d929838bb1278cd460aabb9a6ea76d30 to your computer and use it in GitHub Desktop.
Get balances and rewards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ADDRESS=$1 | |
MAX_HEIGHT=$(curl -sS http://testnet.lto.network/blocks/height | jq '.height') | |
MIN_HEIGHT=$((MAX_HEIGHT - 1999)) | |
curl -sS "https://testnet.lto.network/addresses/balance/history/$ADDRESS" | jq -r '.[] | (.height|tostring) + "," + (.balance|tostring)' > balance.csv | |
BLOCKS=$(for ((HEIGHT=MIN_HEIGHT; HEIGHT<MAX_HEIGHT; HEIGHT=HEIGHT+100)); do curl -sS "http://testnet.lto.network/blocks/address/$ADDRESS/$HEIGHT/$((HEIGHT + 99))" | jq -r '.[].height'; done) | |
(for BLOCK in $BLOCKS; do curl -sS "http://testnet.lto.network/blocks/at/$BLOCK"; done) | jq -r 'select(.generatorReward > 0) | (.height|tostring) + "," + (.generatorReward|tostring)' > reward.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment