-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: verification in forge create with custom explorer when passing --verifier etherscan
with --etherscan-api-key
doesn't work
#9220
Comments
@antoinedc pls check book on how to add unknown chains in config https://book.getfoundry.sh/reference/config/etherscan#etherscan so smth like this should work [rpc_endpoints]
anvil = "http://127.0.0.1:8545"
[etherscan]
anvil = { key = "anvil-23", url = "http://localhost:8888/api", chain = "anvil"} forge create \
--rpc-url anvil \
--private-key 0x2a871d... \
src/Counter.sol:Counter \
--verify
Deployer: 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
Deployed to: 0x700b6A60ce7EaaEA56F065753d8dcB9653dbAD35
Transaction hash: 0xa0c56fe7347058f526206c4dbb7ba92ce70306fdf80bc23bcaf7a86d06a3f149
Starting contract verification...
Waiting for etherscan to detect contract deployment...
Start verifying contract `0x700b6A60ce7EaaEA56F065753d8dcB9653dbAD35` deployed on anvil-hardhat going to close for now, please reopen if still issues. thank you! |
Thanks @grandizzy for the reply. I had actually seen that page before, but I'm looking at being able to do the verification without having to create or edit an extra file, directly in the forge create command. Are there any technical reasons why this can't be supported? This really does make a difference on my end. Contract verification is obviously very important for any explorer, and so is compatibility with user tooling/workflow. Not being able to be a drop-in replacement to Blockscout or Etherscan hurts adoption. And "gatekeeping" this feature to those two explorers seems a bit too opinionated. As an example, Hardhat verification system works perfectly with any endpoint (based on Etherscan API-), and users can switch explorers by just changing a value, without having to change anything in their workflow. |
I see, IMO is easier and cleaner to put an alias in a config file (that could be easily reused in other projects) opposed to change command but I can understand your point.
This is valid in the config I put above too, just specify desired URL anvil = { key = "anvil-23", url = "http://localhost:8888/api", chain = "anvil"} @zerosnacks @yash-atreya could you please share your thoughts? thanks! |
Hi @antoinedc I think this issue arises because you are passing the In lieu of a more generalized solution I would be open to accept a PR that adds your custom explorer Ethereal as an foundry/crates/verify/src/provider.rs Lines 152 to 176 in a428ba6
|
Hi @zerosnacks, Shouldn't this check pass if I provide the key? My assumption was that the command would work as long as the verifier-url is an Etherscan compatible endpoint & that an api key is passed. Thanks for the code snippet, I will take a look at that (have never done any Rust so not sure how it'll go ahah) |
Hi @antoinedc, unfortunately this is due to the incorrect use of the cc @grandizzy, this incorrectly casts to foundry/crates/config/src/lib.rs Line 1296 in 48930a6
foundry/crates/config/src/etherscan.rs Line 263 in 48930a6
I think the simplest solution here is to ask alternative explorers to add themselves to the We should also disallow the Re-opening as there are some action items |
--verifier etherscan
with --etherscan-api-key
doesn't work
--verifier etherscan
with --etherscan-api-key
doesn't work --verifier etherscan
with --etherscan-api-key
doesn't work
Aah got it, I see. Thanks for the explanation! From what I've seen in other verifiers, the "method" (ie etherscan, sourcify, etc...), is more about knowing what api format to expect (and then allowing any endpoint) rather than something that will "force" the usage of a specific platform. |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (a428ba6 2024-10-29T00:21:52.576754000Z)
What command(s) is the bug in?
forge create
Operating System
macOS (Apple Silicon)
Describe the bug
When running:
I get this ouput:
Setting ETHERSCAN_API_KEY env variable does the same
http://localhost:8888/api is an Etherscan compatible API (https://tryethernal.com)
forge verify-contract
works as expected thoughThe text was updated successfully, but these errors were encountered: