-
-
Notifications
You must be signed in to change notification settings - Fork 940
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
useWatchContractEvent doesn't work properly when using watched hooks #3883
Comments
filter are stateful, they don't work on public rpc providers that load balance between several nodes. i think the method needs to be updated to use eth_getLogs polling instead and maintain the filter state locally. i think there is already a fallback looking at viem documentation. |
Could you elaborate on this? useWatchContractEvent doesn't seem to fire when we are expecting it to. You're saying it has something to do with the filtering? Glad to provide dev work once we can identify the problem! |
Ran into the same problem, with the difference that I'm using bare In my case feels like if
edit: related viem issue. Probably nothing to do with the libs, but rather RPC. |
@nikitayutanov I'm having the exact same issue on my end with It works on the rare occasion but it's very intermittent. |
@neocybereth I've changed my RPC provider and it seems to have fixed the problem. |
Describe the bug
I need to listen to events using
useWatchContractEvent
and it's working fine. At the same time I need to watch balance of some address. I'm using technique from v1 to v2 migration guide to watch balance. But when I'm adding ituseWatchContractEvent
doesn't work locally (hardhat
,foundry
) and works from time to time onsepolia
(not every event). At the same timeonError
ofuseWatchContractEvent
triggers often. Example from pinned appError from
hardhat
network:Link to Minimal Reproducible Example
https://stackblitz.com/edit/new-wagmi-cauhct?file=src%2FApp.tsx
Steps To Reproduce
use
useWatchContractEvent
and at the same time other watched valueWagmi Version
^2.5.12 (also tried last version)
Viem Version
^2.8.16 (also tried last version)
TypeScript Version
No response
Check existing issues
Anything else?
No response
The text was updated successfully, but these errors were encountered: