trueblocks-core icon indicating copy to clipboard operation
trueblocks-core copied to clipboard

Etherscan API V1 has been deprecated

Open paulkuhle opened this issue 2 months ago • 1 comments

The Etherscan V1 API has now been fully deprecated. Any request to V1 endpoints throw the following error message:

{"status":"0","message":"NOTOK","result":"You are using a deprecated V1 endpoint, switch to Etherscan API V2 using https://docs.etherscan.io/v2-migration"}

Chifra uses the V1 API to download ABI files from Etherscan (both for the --articulate flag and for the chifra abis CLI command). The relevant code is in src/apps/chifra/pkg/abi/download.go:

	url := fmt.Sprintf(
		"https://api.etherscan.io/api?module=contract&action=getabi&address=%s&apikey=%s",
		address.Hex(),
		key,
	)

This may go unnoticed for a while if you have a large ABI cache and don't need to query from source. It should be easy enough to reproduce by removing an ABI and then re-fetching it:

chifra abis 0xdac17f958d2ee523a2206206994597c13d831ec7 -D
chifra abis 0xdac17f958d2ee523a2206206994597c13d831ec7

I was able to fix this locally by replacing the V1 URL with the new V2 URL:

	url := fmt.Sprintf(
		"https://api.etherscan.io/v2/api?chainid=1&module=contract&action=getabi&address=%s&apikey=%s",
		address.Hex(),
		key,
	)

According to the migration guide, you just need to change the base URL. The rest is a drop-in replacement.

I'd be happy to open a PR with this fix, but given that there's a TODO in the file mentioning a possible rewrite I wanted to open this as an issue first.

paulkuhle avatar Oct 13 '25 21:10 paulkuhle

Thanks. It's fixed in the latest PR we have active. It will get pushed to master shortly.

tjayrush avatar Oct 14 '25 20:10 tjayrush