Last active
September 9, 2017 13:53
-
-
Save pau1m/4a3550689bb072ae937266e366755d20 to your computer and use it in GitHub Desktop.
web 3 find transaction in 12th block
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
let filter = web3.eth.filter('latest') | |
filter.watch(function(error, result){ | |
if (!error) { | |
let confirmedBlockId = web3.eth.blockNumber - 12 | |
web3.eth.getBlock(confirmedBlockId, function(error, res){ | |
if (!error) { | |
if (res.transactions.length > 0) { | |
res.transactions.forEach(function(txId){ | |
web3.eth.getTransaction(txId, function(error, tx) { | |
if (!error && tx.to == account) { | |
console.log('tx in 12th block from: ' + tx.from) | |
} | |
}) | |
}) | |
} | |
} | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment