简体   繁体   中英

Web3j read all the emitted events of a sinle transaction

I have a smart contract method "transferFrom" which, at the end, emits an event "EventTransf". From a java program using web3j I call such a method and I obtain the receipt.

TransactionReceipt tr=contract.transferFrom(from,to, tk).send();

Now, I would read all the emitted events from this method call. I have red about the web3j filter, but I'm only interested in the events emitted inside this call. The code should also work with infura.

Solved. I need to use tr.getLogs() and for each Log object, I call

  List<Type> args = FunctionReturnDecoder.decode(
              log.getData(), Contract.Event_Type.getParameters());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM