Skip to main content
This guide covers Hardhat 3. There is an official migration guide from the Hardhat team.
Hardhat is a smart contracts development tool, perfect if you’re familiar with Javascript/Typescript. This assumes you already have a Hardhat 3 project, setup, and you’re about to deploy and verify next.

Install

Via npm.
npm add --save-dev @nomicfoundation/hardhat-verify

Config

In hardhat.config.ts, import the plugin at the top and add it to the list of plugins. Then, specify a verify config with your Etherscan API key. This key works for most supported chains, otherwise you need to define a CustomChain below.
import { defineConfig } from "hardhat/config";
import hardhatVerify from "@nomicfoundation/hardhat-verify";

export default defineConfig({
  plugins: [
    hardhatVerify,
    // ...other plugins...
  ],
  solidity: "0.8.28",
  networks: {
    sepolia: {
      url: configVariable("SEPOLIA_RPC_URL"),
      accounts: [configVariable("SEPOLIA_PRIVATE_KEY")],
    },
  },
  verify: {
    etherscan: {
      apiKey: "YourEtherscanApiKey",
    },
  },
});

Deploy and Verify (using Hardhat Ignition)

npx hardhat ignition deploy ignition/modules/Counter.ts --network sepolia --verify

Verify an Existing Contract

npx hardhat verify --network sepolia 0xdCBdBAA8404554502B433106e62728B659aCfE3b

Custom Chains

For new chains that have an Etherscan explorer but isn’t supported with Hardhat defaults, you need to add both the networks and chainDescriptor in hardhat.config.ts.
export default defineConfig({
  // ...
  networks: {
    monadTestnet: {
      type: "http",
      chainType: "l1",
      url: configVariable("MONAD_TESTNET_RPC_URL"),
      accounts: [configVariable("MONAD_TESTNET_PRIVATE_KEY")],
    }
  },
  chainDescriptors: {
    10143: {
      name: "monadTestnet",
      blockExplorers: {
        etherscan: {
          name: "Monad Testnet Explorer",
          url: "https://testnet.monadscan.com",
          apiUrl: "https://api.etherscan.io/v2/api",
        },
      },
    }
  },
});
Use the same deploy and verify command as above, but with the updated --network. In this example for monadTestnet
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadTestnet --verify