Created
April 1, 2018 13:41
-
-
Save andrecronje/247dd28f9c93583dbe3528d66740409c to your computer and use it in GitHub Desktop.
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
const Web3 = require('web3') | |
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/<InfuraToken>')) | |
let blockNum = 0 | |
let run = async () => { | |
let addresses = {} | |
while (true) { | |
let blck = blockNum++ | |
let block = await web3.eth.getBlock(blck) | |
if (!block) | |
break | |
console.log('block', blck, 'transactions', block.transactions.length) | |
for(let i = 0; i < block.transactions.length; i++) { | |
let tx = await web3.eth.getTransaction(block.transactions[i]) | |
if (parseInt(tx.value) > 0) { | |
addresses[tx.to] = true | |
} | |
} | |
} | |
let positiveAddresses = [] | |
for (address in addresses) { | |
try { | |
let balance = await web3.eth.getBalance(address) | |
if (balance > 0) { | |
positiveAddresses.push(address) | |
} | |
} catch (err) { | |
console.log(err) | |
} | |
} | |
console.log(positiveAddresses) | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment