0

How to get and decode logs of all transactions of a block in web3?

My question is very similar to: Is there a way to get the logs for all transactions in a block?

But the suggestions were given using a method I didn't find in the web3 documentation.

Is there any way to do this efficiently and using web3?

3
  • I think the answer to this question gives the solution you are looking for.
    – Nal Luksic
    Commented Jun 7, 2023 at 10:56
  • @NalLuksic GetBlock is indeed a great option, but from what I understand if a hash has multiple transactions (like this: etherscan.io/tx/…) the only way to get all data would be through the logs, and this is not possible with GetBlock. Commented Jun 7, 2023 at 12:09
  • Not sure what you mean with "hash", but every block has multiple transactions and every transaction can have multiple events. Now if you want to get event logs for every transaction you can simply use web3.eth.getTransactionReceipt(transactionHash) for eevery transaction in a block.
    – Nal Luksic
    Commented Jun 7, 2023 at 12:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.