feat: support custom Etherscan-compatible API URLs#2738
Closed
feat: support custom Etherscan-compatible API URLs#2738
Conversation
Add optional `url` field to `etherscanApi` chain config so chains with their own Etherscan-compatible block explorers can use a custom base URL instead of the default api.etherscan.io/v2. Both the contract creation tx fetcher and the source code import path respect this override. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcocastignoli
approved these changes
Apr 14, 2026
Member
There was a problem hiding this comment.
lgtm. we can close this since it was already merged by mistake in #2732
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
urlfield to theetherscanApichain configuration, enabling chains with their own Etherscan-compatible block explorers to use a custom base URL instead of the hardcodedhttps://api.etherscan.io/v2/api.Kept separate from #2709 (remote chain config refactor) as that PR is already very large.
Changes
SourcifyChainTypes.tsandSourcifyChain.ts(packages/lib-sourcify): Addurl?: stringtoetherscanApietherscan-util.ts(packages/lib-sourcify):fetchFromEtherscanaccepts optionalcustomBaseUrl. When provided, uses${customBaseUrl}/api?module=contract&action=getsourcecode&...instead of the default Etherscan v2 URLetherscan-util.ts(server): PassessourcifyChain.etherscanApi?.urlthrough to lib-sourcifycontract-creation-util.ts(server):getEtherscanApiContractCreatorFetcheraccepts optionalcustomBaseUrl. When provided, uses${customBaseUrl}/api?module=contract&action=getcontractcreation&...instead of the hardcodedETHERSCAN_APIconstantExample usage (BattleChain Testnet)
Chain definition (
extra-chains.json):{ "name": "BattleChain Testnet", "chain": "ETH", "rpc": ["https://testnet.battlechain.com"], "faucets": [], "nativeCurrency": { "name": "Ether", "symbol": "ETH", "decimals": 18 }, "infoURL": "https://battlechain.com", "shortName": "battlechain-testnet", "chainId": 627, "networkId": 627, "slip44": 1, "explorers": [ { "name": "BattleChain Explorer", "url": "https://explorer.testnet.battlechain.com", "standard": "EIP3091" } ] }Sourcify extension (
sourcify-chains-default.json):With
urlset, both the Etherscan source import (getsourcecode) and the contract creation tx lookup (getcontractcreation) will hithttps://block-explorer-api.testnet.battlechain.com/api?...instead ofapi.etherscan.io.Test plan
npx lerna run buildpassespackages/lib-sourcifytests pass (158 passing)services/serverunit tests pass (69 passing)🤖 Generated with Claude Code