Replies: 9 comments 2 replies
-
@Dylan-Kerler how you resolved this issue? |
Beta Was this translation helpful? Give feedback.
-
I ran into this same issue, anybody has a solution? |
Beta Was this translation helpful? Give feedback.
-
@ShivamDev31 @AleSua93 I am quite certain that it is an issue with ganache not ethersJS. Are you guys using ganache? |
Beta Was this translation helpful? Give feedback.
-
@Dylan-Kerler thanks for the answer! I'm using the Hardhat network... I haven't deployed anywhere else yet though, so it might certainly be an issue with the development network, but I'd have to check. |
Beta Was this translation helpful? Give feedback.
-
Hello, I have the same issue when using ganache-cli. Are you sure that the issue comes from ganache ? |
Beta Was this translation helpful? Give feedback.
-
Can you see #1504 (comment) if that helps? |
Beta Was this translation helpful? Give feedback.
-
Hi zemse, Thank you for your feedback, it helped me to understand and workaround the "issue" ;) |
Beta Was this translation helpful? Give feedback.
-
Temporary solution: const startBlockNumber = await provider.getBlockNumber();
contract.on(filter, (...args) => {
const event = args[args.length - 1];
if(event.blockNumber <= startBlockNumber) return; // do not react to this event
// further logic
}) |
Beta Was this translation helpful? Give feedback.
-
You can also use: provider.once("block", () => {
contract.on(filter, (...args) => { ... })
}); |
Beta Was this translation helpful? Give feedback.
-
The following code is logging out events that have happened in the past.
myContract.on("someEvent", () => console.log("event"))
Expected behavior is that it logs out events only as they come in but it is logging events from 1 block in the past on initial run. I don't want to see the events from 1 block in the past - only the new events.
Beta Was this translation helpful? Give feedback.
All reactions