The EtherscanProvider fails requests because of URL length #1093
Labels
bug
Verified to be an issue.
fixed/complete
This Bug is fixed or Enhancement is complete and published.
Issue
Some
eth_call
requests will always fail for the EtherscanProvider but they succeed with the Infura, Alchemy, Cloudflare and JsonRPC providers.Looking at the requests, etherscan is the only provider using GET requests.
The appended data field can result in the URL reaching extreme lengths, over 6000 characters in the example below.
(Issue found in Chrome & Firefox browsers, might also be a browser enforced limitation)
Solution
The Etherscan API accepts POST requests, and these do succeed in many cases where GET calls fail.
A change to POST for certain request types will make the EtherscanProvider more reliable and increase compatibility with the other providers.
Examples
I tested these in the latest version of Chrome & Firefox.
The following examples call this function:
function tokenBalances(address user, address[] calldata tokens) external view returns (uint[] memory balances)
The EtherscanProvider starts to fail once the token array reaches a length of about 75-100.
Other providers can easily cope with much larger arrays.
The API key has been redacted, you probably have to add one to check these.
Case 1: array length 1
GET succeeds
POST succeeds
Case 2: Array length 100
GET fails
POST succeeds
The text was updated successfully, but these errors were encountered: