I want to query some deposit events to show all deposits for a user.

On Ethereum, I did it like this to query all deposits (starting from block 0)

const block = await provider.getBlockNumber()
const depositStream = await exchange.queryFilter("Deposit", 0, block)

Now I deployed the same smart contract and frontend to Polygon and I get the following error:

block range is too wide

To get this to work I have to limit the range to like 3000 blocks:

const depositStream = await exchange.queryFilter("Deposit", block - 3000, block)

But this will only give me the data of the last 3000 blocks, so like 2 hours. Deposits from a couple of days ago will not show up.

What would be a good approach to query all data on Polygon?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.