Last active
October 25, 2019 18:20
-
-
Save tyrion70/3b2cc065721a5a6b0d4763de90120801 to your computer and use it in GitHub Desktop.
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
| 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(); | |
| }); |
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
| const axios = require('axios') | |
| axios.post('https://mywanwallet.nl/api', | |
| {"jsonrpc":"2.0","method":"eth_blockNumber","id":1} | |
| ) | |
| .then((res) => { | |
| blocknumber = parseInt(res.data.result) | |
| axios.post('https://mywanwallet.nl/api', | |
| {"jsonrpc":"2.0","method":"pos_getStakerInfo","params":[blocknumber],"id":1} | |
| ) | |
| .then((res) => { | |
| validators = res.data.result | |
| let totalstake = 0; | |
| 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) | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment