Skip to content

Instantly share code, notes, and snippets.

@mworzala
Created January 16, 2020 00:14
Show Gist options
  • Save mworzala/96dbf81ccf95eab6844aa886c0ec8e72 to your computer and use it in GitHub Desktop.
Save mworzala/96dbf81ccf95eab6844aa886c0ec8e72 to your computer and use it in GitHub Desktop.
balances fetch
const fetch = require('node-fetch');
(async () => {
let min = 1000000000000000000000;
let max = 0;
for (let j = 0; j < 100; j++) {
await fetch('http://localhost:4001/v1/balances', {
headers: {
'X-Algo-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
}
}).then(resp => resp.json()).then(json => {
const accounts = json.balances;
let total = 0;
for (let i = 0; i < accounts.length; i++)
total += accounts[i].amount;
min = Math.min(min, total);
max = Math.max(max, total);
console.log(`Detected ${accounts.length} with a total of ${total} micro algos`)
});
}
console.log(`Min: ${min}, Max: ${max}, Difference: ${max - min}`)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment