以太坊12个块确认

 

const Web3 = require('web3')
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))

let account = '0x05430f5201585c2601bb75d9658007202864c993'
let filter = web3.eth.filter('latest')
filter.watch(function(error, result) {
  if (!error) {
    let confirmedBlock = web3.eth.getBlock(web3.eth.blockNumber - 11)
    if (confirmedBlock.transactions.length > 0) {
      confirmedBlock.transactions.forEach(function(txId) {
        let transaction = web3.eth.getTransaction(txId)
        if (transaction.to == account) {
          // Do something useful.
        }
      })
    }
  }
})

你可能感兴趣的:(以太坊12个块确认)