Last active
November 22, 2019 08:38
-
-
Save mempirate/c8f693e8d8c64718e75117491a9fc98d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'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