Verify with Foundry

You must update to the nightly build of Foundry to use this at the moment, via foundryup --install nightly

Foundry is a tool that helps take the heat off smart contract development steps 🔥, including compiling, deploying and finally submitting your contract for verification.

Deploy and Verify

forge create --broadcast --rpc-url https://rpc.sepolia.ethpandaops.io --private-key YourPrivateKey src/ContractFile.sol:ContractName --verify --verifier etherscan --etherscan-api-key YourApiKeyToken

Verify an Existing Contract

forge verify-contract --watch --chain sepolia 0x324eca20b358b18e48f2611f7452560ce3b3c1bb src/ContractFile.sol:ContractName --verifier etherscan --etherscan-api-key YourApiKeyToken

Migrating from V1

The easiest way to migrate is to simply pass in your Etherscan key via --etherscan-api-key

For deployment scripts, in foundry.toml you can shorten your settings to this, without needing a different key for each chain.

etherscan_api_key = "VZFDUWB3YGQ1YCDKTCU1D6DDSS6EWI62KV"

[etherscan]
mainnet   = { key = "${ETHERSCAN_API_KEY}" } 

This open source integration was shipped by @iainnash and the Foundry team 🙌

Last updated