Skill 4.3.1

Verify contract source code on a block explorer

Key Concepts

A deployed contract is only bytecode. Source verification submits the source files, compiler version, optimizer settings and constructor arguments to a service, which recompiles them and confirms that the result matches the bytecode on chain. Verified contracts on Etherscan show their source and ABI, and the explorer's Read Contract and Write Contract tabs let anyone interact with them. Sourcify is an open, decentralised verification service, and Blockscout explorers offer verification too.

In Hardhat, npx hardhat verify --network sepolia <address> <constructor args> verifies on all configured explorers (an Etherscan API key is needed for Etherscan), and npx hardhat ignition deploy ... --verify verifies as part of an Ignition deployment. Remix has a verification plugin. Verification fails if any setting differs from the one used at deployment.