Skip to content

bug(forge script): if ETHERSCAN_API_KEY is set and --verify is passed it will try to verify via Etherscan no matter if Etherscan supports the chain #10774

Open
@zerosnacks

Description

@zerosnacks

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 1.2.3-nightly (6fb7c59 2025-06-13T06:02:04.387303000Z)

What version of Foundryup are you on?

foundryup: 1.1.0

What command(s) is the bug in?

forge script --verify with ETHERSCAN_API_KEY environment variable set

Operating System

None

Describe the bug

As reported in #10593 (comment) and #10593 (comment) users are facing an issue if they have an ETHERSCAN_API_KEY set in a scripting environment that deploys to multiple chains as there is no guarantee that the Etherscan API is available on all the target chains.

We should perform a check whether the Etherscan API is available on a chain before attempting to verify.

We should additionally make it so that command line flags always override environment variables. The more explicit the setting is the higher priority it has. This is an example of the behavior: if the user has defined a flag that specifies the --verifier sourcify it should ignore the ETHERSCAN_API_KEY.

If the user does not specify the --verifier / --verifier-url it is the correct behaviour to select the Etherscan API. We should however make sure it actually exists - if it does not we should warn the user. This ties into dry-running behavior as defined in #10593 (comment) - this is out of scope for this ticket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions