Verify contract code with Hardhat in Blockscout

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 = {
  networks{
    b2testnet: {
      url: 'https://b2testnet-rpc.bsquared.network',
      chainId: 1123,
      accounts: {
        mnemonic: process.env.MNEMONIC,
        path: "m/44'/60'/0'/0",
        initialIndex: 0,
        count: 20,
      },
    },
  },
  etherscan: {
    apiKey: {
      b2testnet: "abc"
    },
    customChains: [
       {
        network: "b2testnet",
        chainId: 1123,
        urls: {
          apiURL: "https://b2-testnet.alt.technology/",
          browserURL: "https://testnet-blockscout.bsquared.network/"
        }
      },
      }
    ]
  },

Verify

  1. We can use the following cli to verify

  2. For more features, please refer to

Reference

Last updated