Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: etherscan api 403 when using getDefaultProvider #904

Closed
thegostep opened this issue Jun 24, 2020 · 11 comments
Closed

Bug: etherscan api 403 when using getDefaultProvider #904

thegostep opened this issue Jun 24, 2020 · 11 comments
Labels
investigate Under investigation and may be a bug.

Comments

@thegostep
Copy link

@ricmoo
Copy link
Member

ricmoo commented Jun 26, 2020

Can you try again? I just tested it an it seems to have worked. Maybe Görli (Etherscans fleet) was down at the time?

If you still have issues, I’ll dig into this more.

@thegostep
Copy link
Author

It still occurs, here is a screenshot

image

@ricmoo
Copy link
Member

ricmoo commented Jun 26, 2020

Thanks. I’ll look into it first thing. :)

@ricmoo ricmoo added investigate Under investigation and may be a bug. on-deck This Enhancement or Bug is currently being worked on. labels Jun 29, 2020
@ricmoo
Copy link
Member

ricmoo commented Jun 29, 2020

Heya! Just did some experimenting and can't reproduce it yet, so I have a few questions. :)

  • What version of ethers are you using?
  • Are you using the version created in the dist/ folder of ethers? Or referencing the CDN version?
  • Are you making a lot of requests? Are any earlier ones succeeding? I'm wondering if you are hitting the quota for your IP address with the default key? Can you also try registering your own Etherscan key and trying that?

@thegostep
Copy link
Author

My quick fix was to remove etherscan provider for now - it is possible I am getting throttled so I'll have to check if creating my own api key fixes it

@ricmoo
Copy link
Member

ricmoo commented Jul 19, 2020

Quick question. What browser are you using and what is its user agent?

I spent the last few days debugging a similar issue with the browser tests failing, and I was finally able to determine the issue was the Cloudflare configurations sitting in-front of all the Etherscan testnet hosts (mainnet is fine) were overly aggressively blocking the User-Agent that the headless chrome reports. I fixed it by changing the User-Agent string.

@thegostep
Copy link
Author

I was seeing this in Chrome. @PierrickGT may have more details.

@ricmoo
Copy link
Member

ricmoo commented Jul 21, 2020

Could it have been configured with a custom User-Agent (or maybe a plugin that tweaked it) or had an automated option enabled? Chrome with the --headless option for example changes the user-agent string to something that fails on testnets for Etherscan (works fine for mainnet).

Just a hypothesis, but trying to narow it down.

michaeltout pushed a commit to michaeltout/ethers.js that referenced this issue Aug 23, 2020
@ricmoo
Copy link
Member

ricmoo commented Jan 18, 2023

Closing as I don't believe this is an issue any longer? The EtherscanProvider now passes an empty API key along, which instructs their API to use IP throttling instead of API key throttling.

Thanks! :)

@ricmoo ricmoo closed this as completed Jan 18, 2023
@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Feb 23, 2023
@HappyGroupHub
Copy link

HappyGroupHub commented Mar 20, 2023

I've the same problem before and got solved by doing this!
Add headers as well while doing the request.

url = YourApiCallingUrl
headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
requests.get(url, headers=headers)

Etherscan eventually blocked request that without headers
But it seems only happening in testnets sometimes, which is weird..
But anyways! hopefully helps you out

@ricmoo
Copy link
Member

ricmoo commented Mar 20, 2023

Oh! That usually has to do with their configured Cloudflare heuristics for detecting a bot. This can often be addressed by acquiring your own API key.

It also changes frequently and it hard to predict what rules are in effect and when. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug.
Projects
None yet
Development

No branches or pull requests

3 participants