以太坊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.
        }
      })
    }
  }
})
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章