Skip to content

Instantly share code, notes, and snippets.

@mempirate
Last active November 22, 2019 08:36
Show Gist options
  • Save mempirate/c7e02236dfed6c79e66adfe937cb3d0c to your computer and use it in GitHub Desktop.
Save mempirate/c7e02236dfed6c79e66adfe937cb3d0c to your computer and use it in GitHub Desktop.
async function checkBlocks(start, end) {
for (let i = start; i < end; i++) {
let block = await web3.eth.getBlock(i)
console.log(`[*] Searching block ${ i }`)
if (block && block.transactions) {
for (let txHash of block.transactions) {
let tx = await web3.eth.getTransaction(txHash)
if (account === tx.to.toLowerCase()) {
console.log(`[+] Transaction found on block ${ lastBlockNumber }`)
console.log({ address: tx.from, value: web3.utils.fromWei(tx.value, 'ether'), timestamp: new Date() })
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment