Verifying contracts

Make your contract source code publicly readable on Etherscan — the single most important trust signal in DeFi.

Why verify?

An unverified contract on Etherscan shows only raw bytecode — unreadable to humans. A verified contract shows the full Solidity source code, the ABI, and allows anyone to call functions directly from Etherscan's UI. In DeFi, verification is a baseline trust requirement. Sophisticated users and protocols will not interact with unverified contracts.

Verify with Hardhat

With the @nomicfoundation/hardhat-verify plugin (included in hardhat-toolbox) and an Etherscan API key, verification is a single command.

bash
# Verify a contract with no constructor arguments
npx hardhat verify --network sepolia CONTRACT_ADDRESS

# Verify a contract with constructor arguments
npx hardhat verify --network sepolia CONTRACT_ADDRESS 'arg1' 'arg2'

If your constructor takes complex arguments (arrays, structs), use a constructor arguments file:

javascript
// arguments.js
module.exports = [
  'Token Name',
  'TKN',
  1000000,  // initial supply
];
bash
npx hardhat verify --network sepolia CONTRACT_ADDRESS --constructor-args arguments.js

Verify with Ignition

Hardhat Ignition can verify contracts automatically after deployment:

bash
npx hardhat ignition deploy ignition/modules/MyToken.js \
  --network sepolia \
  --verify

Verify on multiple chains

If you deploy to multiple EVM chains, each has its own block explorer. Configure each in hardhat.config.js:

javascript
etherscan: {
  apiKey: {
    mainnet: process.env.ETHERSCAN_API_KEY,
    sepolia: process.env.ETHERSCAN_API_KEY,
    polygon: process.env.POLYGONSCAN_API_KEY,
    arbitrumOne: process.env.ARBISCAN_API_KEY,
    base: process.env.BASESCAN_API_KEY,
  }
}

After verification

Once verified, Etherscan shows:

  • Full source code with syntax highlighting
  • Read contract tab — call any view function directly
  • Write contract tab — call state-changing functions (requires wallet connection)
  • ABI for developers integrating with your contract

Share the Etherscan link publicly. It's your contract's public profile.

←   Deploying to testnetConnecting to frontends   →