Hardhat Verify

Verify with Hardhat

Hardhat has an Etherscan plugin: Hardhat Etherscan plugin

Note: Hardhat was previously Buidler.

Install the plugin

npm install --save-dev @nomiclabs/hardhat-etherscan

Configure the plugin in buidler.config.js

  • Add require("@nomiclabs/hardhat-etherscan");

  • Add Bscscan API key

Warning

keep secret and don’t commit to version control)

Go to register and get API key: https://testnet-explorer.brisescan.com/myapikey

  • Set compiler version to match what was deployed

// hardhat.config.js
const { mnemonic, bscscanApiKey } = require('./secrets.json');

require('@nomiclabs/hardhat-ethers');
require("@nomiclabs/hardhat-etherscan");
/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {

  networks: {
    testnet: {
      url: `https://testnet-rpc.brisescan.com`,
      accounts: {mnemonic: mnemonic}
    },
    mainnet: {
      url: `https://nc-dataseed.brisescan.com/`,
      accounts: {mnemonic: mnemonic}
    }
  },

  etherscan: {
    // Your API key for Etherscan
    // Obtain one at https://testnet-explorer.brisescan.com/
    apiKey: bscscanApiKey
  },
  solidity: "0.5.12"
};

Verify

Warning

Remove any unnecessary contracts and clear the artifacts otherwise these will also be part of the verified contract.

Run the following command:

  • Example

Last updated