Code of honor: This tutorial is based on the post from Thanks for your contributions!

Hardhat has an Etherscan plugin: Hardhat Bscscan plugin

Please read this blog to lean about the fundamentals of Hardhat.

Install the plugin

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

Go to BSCScan and register an API key:

Configure the plugin in buidler.config.js

  • Add require("@nomiclabs/hardhat-etherscan");
  • Add Bscscan API key
keep secret and don’t commit to version control
  • Set compiler version to match what was deployed
// hardhat.config.js
const { mnemonic, bscscanApiKey } = require('./secrets.json');

 * @type import('hardhat/config').HardhatUserConfig
module.exports = {

  networks: {
    testnet: {
      url: ``,
      accounts: {mnemonic: mnemonic}
    mainnet: {
      url: ``,
      accounts: {mnemonic: mnemonic}

  etherscan: {
    // Your API key for Etherscan
    // Obtain one at
    apiKey: bscscanApiKey
  solidity: "0.5.12"


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

Run the following command:

npx buidler verify --network mainnet DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1"
$ npx hardhat  verify --network testnet 0xbF39886B4F91F5170934191b0d96Dd277147FBB2
Nothing to compile
Compiling 1 file with 0.5.16
Successfully submitted source code for contract
contracts/BEP20Token.sol:BEP20Token at 0xbF39886B4F91F5170934191b0d96Dd277147FBB2
for verification on Etherscan. Waiting for verification result...

Successfully verified contract BEP20Token on Etherscan.