Search code examples
ethereumweb3js

How do I decode events of a transaction from the transaction receipt?


On Etherscan it shows Swap, Remove Liq, Transfer, migrate etc... How do I decode this information from a TransactionReceipt using web3 API?

Currently, I see patterns on Liq removal such as a Null Address in the logs. Is this the way etherscan does it or is there a way to extract method type?


Solution

  • What you are looking for is called event signature in Solidity terminology. The event log first 4 bytes match the hash of an event ABI descriptor.

    To decode, you need to have the ABI files of the events you are decoding. With the ABI file, you can decode the rest of the event data and convert it to human-readable info.

    More here.