Why can't we scan the full events/logs for Polygon?

It’s been documented elsewhere in this forum that the Polygon getPastLogs API behaves differently to mainnet ETHEREUM.

For a while there was a hard limit of 100,000 blocks per request.

But recently, this seems to have been dropped without notice to 3,500.

For example, we could make a request to ETH like this to find the ERC721 Transfer events for a given token ID:

const scan = await web3.eth.getPastLogs({
      address,
      topics: [transferTopic, null, null, tokenId],  // Scan for the ERC 721 Transfer topic for a given tokenId 
      0,  // From block
      'now', // To block
    })

(And for the record, the token ID should be indexed according to the spec:

event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);

)

…and as long as the total number of events returned doesn’t exceed some large value, it works in a timely manner. But if we try the same on Polygon we get an error:

eth_getLogs block range too large, range: 119593, max: 3500

So my question is, is there any chance Infura will implement this for Polygon?

Is it just simply it hasn’t been implemented yet or is this a fundamental limit due to the scale of Polygon?

Our use case is being able to find the full Transfer even history for NFTs so it’s quite a pain that we can’t do this with Infura.

Thanks!

Hi @John_Wood and welcome to the Infura community!

As of now the limit on Polygon is 3500, we are looking into scaling this but the team does not have a timeline for it just yet, hopefully soon.

Just to add my 2 cents - any block number limitation makes this function 100% unusable.
Example: getLogs for $args = [
‘fromBlock’ => ‘0x0’,
‘toBlock’ => ‘latest’,
‘address’ => ‘0xC793029F27041Df196749f1719A6a8be82Fe371E’,
‘topics’ => [
‘0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef’, //Keccak(‘Transfer(address,address,uint256)’)
null, // from
null, // to
‘0x213670E3F47BBAB4C225C9BCE21518364D9BC514253C8114AFE069C6925EACB0’,
],
];
For Polygon mainnet it is a lookup for 1 record from less then 100 records. It should be just instant, but with this limitation it forces me to scan all polygon mainnet blocks which is just nonsense.

Again, this issue is not a limitation, it is an Ethereum JSON RPC API standard violation that makes the getLogs function totally useless for dApps.

Best regards,
Oleg Abrosimov
ethereumico.io CEO

1 Like

Agree. And, for us it is our main reason for probably moving off Infura.

I know this is painful and thanks for the patience, we’re close to releasing an improved mechanism for fetching logs in Polygon and that limit will considerably increase as well.

Thanks @traian.vila that’s great to know and I appreciate that.

Although I would say that just increasing the limit is not really solving the problem for us, if we can’t scan from block zero. As @olegabrosimovnsk mentions, a common pattern is to want to look up all events from the beginning of time. So even if the range was huge, like 100k, this would still need hundreds of calls for each thing you want to lookup.

any update on this @traian.vila? im getting the same error on mumbai, not clear whether that will apply to polygon mainnet and cant find anything in docs.

does this limit go up at higher pricing tiers?

hey Sam, what’s the error you’re getting ? As far as I know this was extended to 10k results on Polygon too.

does this limit go up at higher pricing tiers?
no, it’s the same for all tiers.

Came here to say that we are experiencing this issue at 3500 block range as a paid user and we will be moving off Infura for this reason.

Alchemy free tier has this capability.