web3modal
web3modal copied to clipboard
useContractEvent add queryFilter parameter
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...
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.
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.
We have moved over to using wagmi fully for web3modal (https://wagmi.sh) so this could now become a feature request in their lib.