ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

contract.on(event, ...) returns event happened prior ?

Open garyng2000 opened this issue 3 years ago • 4 comments

Ethers Version

5.6.9

Search Terms

event listening

Describe the Problem

I am trying to use the contract.on(event,...) to watch event happening and is expecting it to be only future events. But it seems that somehow it returns the event since contract deployment.

Is my understanding wrong about this ?

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

garyng2000 avatar Aug 12 '22 13:08 garyng2000

~This should not happen generally. Can you provide which environment are you using? e.g. ganache, hardhat, geth and on which network mainnet, testnet.~

Edit: just noticed that its a known issue https://github.com/ethers-io/ethers.js/pull/3094#issuecomment-1190741714

zemse avatar Aug 13 '22 15:08 zemse

Related to https://github.com/ethers-io/ethers.js/pull/3094 ?

osis avatar Aug 15 '22 02:08 osis

@osis My guess is yes. The fix will be going out tomorrow; you can try with 5.7 once it is released. :)

ricmoo avatar Aug 15 '22 03:08 ricmoo

thanks for the info, I was running geth node but on a private POA network which creates block on demand, when there is new txn (i.e. basically the same as a dev network but is shared/synced between different machines).

will try out 5.7 when it is out

garyng2000 avatar Aug 15 '22 05:08 garyng2000