Verify contract code with Hardhat in B² Explorer

Install plugin

  1. npm install --save-dev @nomicfoundation/hardhat-verify

  2. And add the following statement to your hardhat.config.js:

    require("@nomicfoundation/hardhat-verify");

    Or, if you are using TypeScript, add this to your hardhat.config.ts:

    import "@nomicfoundation/hardhat-verify";

Config hardhat.config.js or hardhat.config.ts

module.exports = {
  solidity: "0.8.28",
  networks: {
    b2: {
      url: "https://rpc.bsquared.network",
      chainId: 223,
      accounts: "abc",
    },
  },
  etherscan: {
    apiKey: {
      b2: "no-api-key",
    },
    customChains: [
      {
        network: "b2",
        chainId: 223,
        urls: {
          apiURL: "https://12d6a1773a-backend-blockscout.bsquared.network/api/",
          browserURL: "https://explorer.bsquared.network",
        },
      },
    ],
  },
  sourcify: {
    enabled: false,
  },
}

Verify

  1. We can use the following cli to verify

  2. For more features, please refer to

Reference

Last updated