web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

useContractEvent add queryFilter parameter

Open jellohouse opened this issue 2 years ago • 1 comments

I'm trying to read old events from a smart contract using the useContractEvent hook.

But there is no queryFilter parameter so I cannot set which block number range I want it to search from...

jellohouse avatar Oct 21 '22 18:10 jellohouse

We use https://wagmi.sh/docs/hooks/useContractEvent under the hood for this and as of now it doesn't look like you can read old events. I think intention here is to read "old" data from contract.

I'll flag this as feature-request and will check if it is achievable once we release stable version.

xzilja avatar Oct 22 '22 08:10 xzilja

Actually for this I think it should be a new hook. Because useContractEvent is really for subscribing to live events (which is why we provide it a callback function)

Ideally I think this should be a new hook like usePastEvents or something like that in which you could provide optional parameters like the block numbers from which to read, and filter parameters, etc.

jellohouse avatar Oct 28 '22 15:10 jellohouse

We have moved over to using wagmi fully for web3modal (https://wagmi.sh) so this could now become a feature request in their lib.

xzilja avatar Nov 21 '22 18:11 xzilja