createContractEventFilter
returns no events without setting a fromBlock
#947
Unanswered
DannyDelott
asked this question in
Question
Replies: 1 comment
-
Isn’t this expected? I’d expect for it to create a filter at the latest block. Changing this would be a breaking change, and I would rather have the behaviour in sync with the node. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there an existing issue for this?
Package Version
1.4.2
Current Behavior
The
fromBlock
arg is typed as optional increateContractFilter
, but you won't get any events back without it.Expected Behavior
If you don't pass a
fromBlock
, it should default to"earliest"
. At a minimum, this keeps the mental model the same between viem and ethers. (see: https://docs.ethers.org/v6/api/contract/#BaseContract-queryFilter)Steps To Reproduce
See repro example
Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)
https://stackblitz.com/edit/viem-getting-started-3nq49j?file=index.ts,erc20.ts,index.html
Anything else?
Beta Was this translation helpful? Give feedback.
All reactions