How do I get all the logs for a given transaction, across all contracts executed in the transaction? #2895
-
Hi, I'm trying to piece together some data from Uniswap v3 positions. Uniswap v3 'add' and 'remove' liquidity transactions emit a bunch of logs. Some of these are emitted by the Uniswap Positions NFT contract, but others are emitted by the ERC-20 token contracts involved in the pool we're adding to/removing from. Example 'add' transaction logs: https://etherscan.io/tx/0x3766f3eccfdd6c8ad9fde50f6496dcc15a0988063e5493651d6f4fdbe7590aa5#eventlog Example 'remove' transaction logs: https://etherscan.io/tx/0x74aa183831ed9dd9672807c6768b570e11e3c9700d3ad151e315bfc8000a83ee#eventlog Suppose I have a list of transaction hashes, some of which are 'add' and 'remove' transactions. How do I get the full set of logs for each transaction? Here's what I can filter by when calling
It looks like there's no way to filter by transaction hash. I can iterate through my transactions and get the block numbers. But I still need to call Am I missing a trick here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you have the transaction hash, you can use It might make sense in v6 for me to add a |
Beta Was this translation helpful? Give feedback.
If you have the transaction hash, you can use
provider.getTransactionReceipt(hash)
. To parse all the events into Event objects, you can usetx.logs.map((log) => contract.interface.parseLog(log))
.It might make sense in v6 for me to add a
contract.queryTransaction(hash)
method. I've added a stub for now to investigate further. :)