web3j监听合约logs事件

时间:2025-03-27 07:14:33
  • var subscription = web3('logs', {
  •     fromBlock: 'latest',
  •     topics: [[
  •         '0x6127e12f74881841fd4934157f9e683c0613e448f51dade259b7566cfb549591',
  •         '0xe1abff435c7322cf9407bef24e299a6533554209c66839f7e1f93db109d318d2', // Payout
  •         '0x233e08447f8306452db45f9f8a63d4728bc76ce9dfdac80fa38687dc5d895135']
  •     ]
  • }, function(error, result){
  •     if(!error){
  •         ("subscription result:",result);
  •     }else {
  •         logger.error("subscription error:",error);
  •     }
  • }).on("data", function(log){
  •     ("subscription data:",log);
  • });