Ethers.js has ContractReceipt
which extends TransactionReceipt
that includes an array of events from the transaction: https://github.com/ethers-io/ethers.js/blob/master/packages/contracts/src.ts/index.ts#L99
Is it possible to get this array using Wagmi? The docs say that wagmi now returns the Viem TransactionReceipt
instead of Ethers, and it doesn't look like it has ContractReceipt
: https://github.com/wagmi-dev/viem/blob/136c4022c3ab4020f37333876bed788a111bff47/src/types/transaction.ts#L12
I figured it out:
You need to parse the logs yourself from the Wagmi/Viem transaction receipt. I modified the answer in this post: https://github.com/ethers-io/ethers.js/issues/487
The events will be present in
logged
underargs
.