Last active
October 7, 2021 22:20
-
-
Save Beasta/214136e501160407c924d8b89e9c7e34 to your computer and use it in GitHub Desktop.
A simple script to extract your helium node's penalty history. Offers a little more history than is available on the website.
This file contains 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
// you'll need to run ```npm i lodash cross-fetch``` first to install the packages | |
// next, to run it: ```node validator-penalties.js "your-node-name"``` | |
// this script assumes no collisions in node names, which does occur in the wild | |
const _ = require('lodash'); | |
const fetch = require('cross-fetch'); | |
const findMe = process.argv[2]; | |
(async () => { | |
try { | |
const res = await fetch(`https://explorer-api.helium.com/api/validators`); | |
if (res.status >= 400) { | |
throw new Error("Bad response from server"); | |
} | |
const validators = await res.json(); | |
console.log(`res.status is ${res.status}`); | |
const theCatch = _.find(validators,(validator) => { | |
return validator.name === findMe; | |
}); | |
const penalties = theCatch.penalties; | |
console.table(penalties); | |
} catch (err) { | |
console.error(err); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment