Skip to content

Instantly share code, notes, and snippets.

@pau1m
Last active March 9, 2017 12:22
Show Gist options
  • Save pau1m/d8c64bd9e311849e25ed50ff98e56ec4 to your computer and use it in GitHub Desktop.
Save pau1m/d8c64bd9e311849e25ed50ff98e56ec4 to your computer and use it in GitHub Desktop.
Alice in chains
const Web3 = require('web3')
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
let account = '0xE767aEB31dAAF66366999F72FB5De2CEEA76c277'.toLowerCase()
let filter = web3.eth.filter('latest')
filter.watch(function(error, result) {
if (!error) {
let confirmedBlock12 = web3.eth.getBlock(web3.eth.blockNumber - 11)
confirmedBlock12.transactions.forEach(function(txId) {
let transaction = web3.eth.getTransaction(txId)
if (transaction.to == account) {
// Do something useful (eg send a message)
console.log(transaction.from)
}
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment