Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrecronje/247dd28f9c93583dbe3528d66740409c to your computer and use it in GitHub Desktop.
Save andrecronje/247dd28f9c93583dbe3528d66740409c to your computer and use it in GitHub Desktop.
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