-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event listener is giving old events #1096
Comments
@Dylan-Kerler how you resolved this issue? |
I ran into this same issue, anybody has a solution? |
@ShivamDev31 @AleSua93 I am quite certain that it is an issue with ganache not ethersJS. Are you guys using ganache? |
@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. |
Hello, I have the same issue when using ganache-cli. Are you sure that the issue comes from ganache ? |
Can you see #1504 (comment) if that helps? |
Hi zemse, Thank you for your feedback, it helped me to understand and workaround the "issue" ;) |
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
}) |
You can also use: provider.once("block", () => {
contract.on(filter, (...args) => { ... })
}); |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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.
The text was updated successfully, but these errors were encountered: