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

Failed to fetch ABI for contract when using the "Etherscan contract link" option #1419

Open
racket2000 opened this issue Jan 8, 2025 · 4 comments

Comments

@racket2000
Copy link

Version

10.9.0

Current behavior

When I try to index the Chainlink token contract, using the following EtherScan url as input, I receive 2 different errors:

https://etherscan.io/token/0x514910771af9ca656af840dff83e8264ecf986ca

Error 1:
⚠ Failed to fetch ABI for contract 0x514910771af9ca656af840dff83e8264ecf986ca. Marking as unverified. Error: "undefined" is not valid JSON

Error 2:
⚠ Unable to fetch contract deployment block number from block explorer. Error: Cannot read properties of undefined (reading 'slice')

Since the ABI and block number is not fetched properly from EtherScan, I receive an error when running "npm run dev":

ERROR build Failed build
BuildError: Validation failed: Found 0 registered indexing functions.

Expected behavior

When I utilize an Etherscan template, the ABI and functions should automatically be populated.

However, I am currently getting a file named "UnverifiedContractAbi.ts" in the "abis" directory, and a file named "UnverifiedContract.ts" in the "src" directory.

Steps to reproduce

This issue can be reproduced by:

  1. running the following command:
    npm create ponder@latest
  2. Selecting the Etherscan contract link Template Option.
  3. Utilizing the following URL as input:
    https://etherscan.io/address/0x514910771af9ca656af840dff83e8264ecf986ca

Link to repository

No response

Anything else?

No response

@racket2000
Copy link
Author

Note: I did not set my EtherScan API Key. I am not sure if this is necessary.

@racket2000
Copy link
Author

racket2000 commented Jan 8, 2025

Update

After inspecting the source code here, I learned that you can set the EtherScan API key via the following command:

export ETHERSCAN_API_KEY=<YOUR_API_KEY>

I had to do this before running the npm create ponder@latest command.

I suggest adding this info to relevant documentation such as here.

On another note, I was unable to get the -t / --template flag to work. I believe that section in the above documentation may be outdated. (i.e I was not able to set my API Key with the --etherscan-api-key flag.)

I hope this helps make the "Getting Started" guide more straightforward for new users of ponder. Please do let me know if you have any questions.

@typedarray
Copy link
Collaborator

Thanks for opening! Was able to reproduce.

It looks like the root cause is that Etherscan has stopped serving API requests without an API key, which is a real shame. Until recently, they served unauthenticated requests with a restricted rate limit, and create-ponder was designed to comply with the rate limit if no API key was provided. I don't see anything about this in their docs though. They are rolling out a V2 API, could be related. Will do some more digging.

If there's no workaround, we'll probably need to change the etherscan template to require an API key, and improve the error logging around this.

@racket2000
Copy link
Author

Hello, you are very welcome, and I am glad to bring this finding to your attention!

I originally thought I made a "silly mistake" at first by not setting the API Key, but your explanation makes perfect sense.

That is definitely a bit unfortunate that EtherScan got rid of their non-authenticated option, but I am sure that you will be able to find a nice workaround

Can the EtherScan template be used with other block explorers? If it can be, it may be something to keep in mind (i.e other block explorers may not require auth (aka an API Key).

PS: I have just started experimenting with Ponder, and I am quite impressed! It is awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants