Verify via Hardhat
Hardhat v3
This page covers Hardhat v3. For Hardhat v2, see the hardhat-verify plugin docs.
The @nomicfoundation/hardhat-verify plugin has built-in Sourcify support. No configuration is needed — Sourcify verification runs automatically when you run hardhat verify.
Setup
The plugin comes pre-installed in Hardhat v3 template projects. To add it manually:
npm install --save-dev @nomicfoundation/hardhat-verify
hardhat.config.ts
import { defineConfig } from "hardhat/config";
import hardhatVerify from "@nomicfoundation/hardhat-verify";
export default defineConfig({
plugins: [hardhatVerify],
});
Verification
After deploying, verify on all services (Etherscan, Blockscout, Sourcify) with:
npx hardhat verify --network mainnet DEPLOYED_CONTRACT_ADDRESS
To verify on Sourcify only:
npx hardhat verify sourcify --network mainnet DEPLOYED_CONTRACT_ADDRESS
Custom Sourcify instance
If you're running your own Sourcify instance, configure the endpoints under verify:
hardhat.config.ts
export default defineConfig({
plugins: [hardhatVerify],
verify: {
sourcify: {
// Specify a different Sourcify server here
apiUrl: "https://sourcify.dev/server",
},
},
});