Skip to content

Instantly share code, notes, and snippets.

@tyrion70
Created October 25, 2019 18:04
Show Gist options
  • Select an option

  • Save tyrion70/3eb669cfdd029d0c9ff7d1cc48028f98 to your computer and use it in GitHub Desktop.

Select an option

Save tyrion70/3eb669cfdd029d0c9ff7d1cc48028f98 to your computer and use it in GitHub Desktop.
const iWanClient = require('iwan-sdk');
// MAINNET
let apiClientMain = new iWanClient('YOUR-API-KEY, YOUR-SECRET-KEY');
let totalstake = 0;
apiClientMain.getCurrentStakerInfo("WAN",(err, validators) => {
if (err) {
console.log(err);
} else {
for (b in validators) {
totalstake += parseInt(validators[b].amount) / 1000000000000000000
for (i = 0; i < validators[b].partners.length; i++) {
totalstake += parseInt(validators[b].partners[i].amount) / 1000000000000000000
}
for (i = 0; i < validators[b].clients.length; i++) {
totalstake += parseInt(validators[b].clients[i].amount) / 1000000000000000000
}
}
console.log(totalstake)
}
apiClientMain.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment