"Exceed maximum block range: 5000" on contract.queryFilter #1816
-
Hi all, My purpose is to query events of a specific contract and store the transaction hashes of those events into my database. However, I encountered the error const events = await contract.queryFilter(contract.filters.EventName()); I also tried to implement a "paging behavior" by getting the blockNumber first and did an implementation as following: // inside a loop
const events = await contract.queryFilter(contract.filters.EventName(), blockNumber - 5000 * (i+1), blockNumber - 5000 * i); The query succeeded for a few iterations and then always encountered an error as following, somewhere in the middle of the loop. processing response error (body="{\"id\":0,\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32603,\"message\":\"handle request error\"}}", error={"code":-32603}, requestBody="{\"method\":\"eth_getLogs\",\"params\":[{\"fromBlock\":\"0x922b5e\",\"toBlock\":\"0x923afe\",\"address\":\"0xd0d6bfce25876aebd50d884b35aae7b8b7f0193d\",\"topics\":[\"0x76264100b4b20aa06c294636c2e40aaf398c3490112488330659f4577010713f\"]}],\"id\":46,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="https://bsc-dataseed.binance.org/", code=SERVER_ERROR, version=web/5.4.0) Wonder if there is any other strategy to achieve my purpose. Really appreciate any comments and helps. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
It’s up to each node operator as to what window they want to expose. The BSC network is not very reliable for these sorts of things, but if you run your own node you might have better luck, but may still experience timeouts. INFURA for example, on Ethereum has a completely custom solution where all logs are stored and indexed in a database. You may need to do something similar, depending on your use case. If you do find another solution though, please let me know. There are more people trying out BSC these days, so I’m sure future peeps would appreciate anything you find. :) |
Beta Was this translation helpful? Give feedback.
-
The temporary solution is to use BscScan APIs, which can be read more at https://bscscan.com/apis#logs. |
Beta Was this translation helpful? Give feedback.
The temporary solution is to use BscScan APIs, which can be read more at https://bscscan.com/apis#logs.
This solution may not be the most ideal one, in my opinion.