Skip to content

Instantly share code, notes, and snippets.

@mempirate
Last active November 22, 2019 08:38
Show Gist options
  • Save mempirate/c8f693e8d8c64718e75117491a9fc98d to your computer and use it in GitHub Desktop.
Save mempirate/c8f693e8d8c64718e75117491a9fc98d to your computer and use it in GitHub Desktop.
'use strict'
module.exports = web3 => {
const account = 'YOUR_ETH_ADDRESS'.toLowerCase()
return async function checkLastBlock() {
let block = await web3.eth.getBlock('latest')
console.log(`[*] Searching block ${ block.number }...`)
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