-
This is the
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
The (moving to discussions) |
Beta Was this translation helpful? Give feedback.
-
I just ran into this issue today. The confusing thing is, getting transaction events works fine in Ethers version 5.7.2. |
Beta Was this translation helpful? Give feedback.
-
I have been having trouble with this trying to write smart contract tests with Hardhat on Ethers v6. All of my Googling brought me here, as well as some v5 code that doesn’t work ( Whenever I would Instead, I found that contracts have a Here is the code I was able to get working. const { factory, owner } = await loadFixture(deployExampleContractFactoryFixture);
const tx = await factory.newExampleContract();
const receipt = await tx.wait();
const events = await factory.queryFilter(factory.filters.ExampleContractCreated, receipt?.blockNumber, receipt?.blockNumber)
const addressString = events[0].args[0];
const newContract = await ethers.getContractAt("ExampleContract", addressString, owner);
expect(await newContract.someValue()).to.equal(0) Another way (and possibly the intended way) to do it is to use ContractTransactionReceipt.logs, which returns Array< EventLog | Log >. However, I struggled with this because TypeScript is new to me and I couldn’t figure out how to transform that into an array of event logs. |
Beta Was this translation helpful? Give feedback.
The
events
property is only available on a ContractReceipt (see the docs), as a normal receipt does not have access to the ABI.(moving to discussions)