Replies: 3 comments 3 replies
-
If you query the node afterwards for the logs, do they exist? Or if you try after a few seconds to get the transaction receipt by its hash? Can you also use |
Beta Was this translation helpful? Give feedback.
-
const tx = await contract.someFunction(param1, param2...);
const receipt = await tx.wait();
const filter = contract.filters.EventNameHere;
const events = await contract.queryFilter(filter, -1);
const args = events[0].args; ethers v6 |
Beta Was this translation helpful? Give feedback.
-
I'm still confused.... This is confirmed in this issue #2207, but a I'm using hardhat's const contractFactory = await hre.ethers.getContractFactory('Contract')
const contract = await contractFactory.deploy()
await contract.deploymentTransaction().wait(); // Updated for v6 This returns a I'm able to use @yuercl 's solution to get events, but how do I guarantee the specific transaction the events are coming from? It just calls the contract instance, and I'm guessing it pulls the most recent events but I store my tx receipts and extract events later on, once the order is mixed up. I used to do it like this: function parseLogs(receipt, contract) {
const events = receipt.logs
.filter((x) => x.address === contract.target) // Updated from .address to .target
.map((log) => contract.interface.parseLog(log));
} |
Beta Was this translation helpful? Give feedback.
-
Ethers version
6.8.1
Hello guys, i am not sure why i cant see the logs events using
await tx.wait()
, here is the situation :[ works ] hardhat
npx hardhat test
, the logs here has values and are not empty[ not works ] backend
npx hardhat node --network local
, this runs inhttp://127.0.0.1:8545/
await tx.wailt()
i cant get logs events, i mean i can, but are emptymaybe i am doing something wrong, based in my understanding i have the next code :
Solidity code
[ Code ] Trying to get the logs
[ output ] result transaction
[ output ] logs transaction
When i see the
console.log('logs transaction => ', (receipt as any).logs);
output i see the next :What i am doing wrong ? , i have here some few hours trying to understand why i can see the output in the hardhat test but not in my backend
Thanks for read ❤️
Beta Was this translation helpful? Give feedback.
All reactions