View on GitHub

web3js-cn

web3.eth.filter

监听合约事件。

调用:

web3.eth.filter(array (, options) )

参数:

返回值:

Object - 有下述方法的过滤对象:

监听回调的返回值:

示例:

var filter = web3.eth.filter('pending');

filter.watch(function (error, log) {
  console.log(log); 
  //  {"address":"0x0000000000000000000000000000000000000000", "data":"0x0000000000000000000000000000000000000000000000000000000000000000", ...}
});

// get all past logs again.
var myResults = filter.get(function(error, logs){ ... });

...

// stops and uninstalls the filter
filter.stopWatching();

教程推荐: