Skip to content

Instantly share code, notes, and snippets.

@jasny
Created April 29, 2022 17:49
Show Gist options
  • Save jasny/5a8e6839d2071071b1bf7601f558ef97 to your computer and use it in GitHub Desktop.
Save jasny/5a8e6839d2071071b1bf7601f558ef97 to your computer and use it in GitHub Desktop.
Get balances of all accounts from all 3 LTO bootstrap nodes
#!/bin/bash
if [ $# -gt 0 ]; then
HEIGHT=$1
CONFIG="
url = \"http://node-bs1.lto.network:6869/debug/stateAtHeight/$HEIGHT\"
output = \"balances-bs1.json\"
url = \"http://node-bs2.lto.network:6869/debug/stateAtHeight/$HEIGHT\"
output = \"balances-bs2.json\"
url = \"http://node-bs3.lto.network:6869/debug/stateAtHeight/$HEIGHT\"
output = \"balances-bs3.json\"
url = \"http://node-bs1.lto.network:6869/supply/at/$HEIGHT\"
output = \"supply-bs1.json\"
url = \"http://node-bs2.lto.network:6869/supply/at/$HEIGHT\"
output = \"supply-bs2.json\"
url = \"http://node-bs3.lto.network:6869/supply/at/$HEIGHT\"
output = \"supply-bs3.json\"
"
else
CONFIG="
url = \"http://node-bs1.lto.network:6869/debug/state\"
output = \"balances-bs1.json\"
url = \"http://node-bs2.lto.network:6869/debug/state\"
output = \"balances-bs2.json\"
url = \"http://node-bs3.lto.network:6869/debug/state\"
output = \"balances-bs3.json\"
url = \"http://node-bs1.lto.network:6869/supply\"
output = \"supply-bs1.json\"
url = \"http://node-bs2.lto.network:6869/supply\"
output = \"supply-bs2.json\"
url = \"http://node-bs3.lto.network:6869/supply\"
output = \"supply-bs3.json\"
"
fi
curl -sS --parallel --parallel-immediate --header "X-API-Key: $LTO_API_KEY" --config - <<< $CONFIG
awk -F ' : ' '{gsub(/^[ \t]+|,$/, ""); if ($2 != "") { print $1","$2} }' < balances-bs1.json > balances-bs1.csv
awk -F ' : ' '{gsub(/^[ \t]+|,$/, ""); if ($2 != "") { print $1","$2} }' < balances-bs2.json > balances-bs2.csv
awk -F ' : ' '{gsub(/^[ \t]+|,$/, ""); if ($2 != "") { print $1","$2} }' < balances-bs3.json > balances-bs3.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment