Hardhat

Learn how to verify smart contracts on the Filecoin network using Hardhat with various verification services including Blockscout, Sourcify, and Filfox.

This guide shows you how to verify your smart contracts using Hardhat on the Filecoin network.

Prerequisites

  • A Hardhat project set up for Filecoin development

  • If you don't have a Hardhat project, check out the FEVM Hardhat Kit

  • A deployed contract address

  • Contract constructor arguments (if any)

Verification Methods

Blockscout Verification

Blockscout is a popular blockchain explorer that supports contract verification. Add the following configuration to your hardhat.config.ts:

const config: HardhatUserConfig = {
  solidity: {
    ...
  },
  networks: {
    filecoin: {
      ...
    },
    calibration: {
      ...
    },
  },
  // Configuration for hardhat-verify plugin with Blockscout API
  etherscan: {
    apiKey: {
      filecoin: "empty",
      calibration: "empty",
    },
    customChains: [
      {
        network: "filecoin",
        chainId: 314,
        urls: {
          apiURL: "https://filecoin.blockscout.com/api",
          browserURL: "https://filecoin.blockscout.com",
        },
      },
      {
        network: "calibration",
        chainId: 314159,
        urls: {
          apiURL: "https://filecoin-testnet.blockscout.com/api",
          browserURL: "https://filecoin-testnet.blockscout.com",
        },
      },
    ],
  }
};

export default config;

Verify on Filecoin Mainnet:

Verify on Calibration Testnet:

Troubleshooting: If your contract appears already verified but shows a mismatch, use the --force flag:

Sourcify Verification

Sourcify provides decentralized contract verification. Include the Blockscout configuration above and add the following Sourcify configuration:

This configuration enables dual verification on both Sourcify and Blockscout when running the npx hardhat verify task.

For more information, see the Sourcify documentation.

Filfox Verification

Filfox is the native Filecoin explorer with dedicated verification support.

Installation:

Install the @fil-b/filfox-verifier package into your Hardhat project.

Configuration: Import the plugin in your Hardhat configuration file. This will add the verifyfilfox task into your Hardhat project!

Usage:

For detailed information, see the @fil-b/filfox-verifier documentation.

Was this page helpful?

Last updated

Was this helpful?