0

I am creating an ERC20 token using Openzeppelin's ERC20 contract, I wrote the deploy script using hardhat-deploy and it is running. But, when trying to run the hardhat verify script on that smart contract's address, I get the following error:

NomicLabsHardhatPluginError: More than one contract was found to match the deployed bytecode.
Please use the contract parameter with one of the following contracts:
  * @openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
  * contracts/TopGToken.sol:TopGToken

For example:

  hardhat verify --contract contracts/Example.sol:ExampleContract <other args>

If you are running the verify subtask from within Hardhat instead:

  await run("verify:verify", {
    <other args>,
    contract: "contracts/Example.sol:ExampleContract"
  };

Here is my smart contract:

// SPDX-Licence-Identifier: MIT

pragma solidity ^0.8.16;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract TopGToken is ERC20 {

  constructor(uint256 initialSupply, string memory name, string memory symbol) ERC20 (name, symbol) {
    _mint(msg.sender, initialSupply);
  }
}

Here is my deploy file:

const { network } = require('hardhat');
const { networkConfig, devChains } = require('../network.config');
const { verify } = require('../utils/verify');

module.exports = async ({ getNamedAccounts, deployments }) => {
  const { deploy, log } = deployments;
  const { deployer } = await getNamedAccounts();

  const currentNetwork = networkConfig[network.config.chainId];
  const isLocal = devChains.includes(currentNetwork.name);
  
  const initialSupply = currentNetwork.initialSupply;
  const name = "Top G Token";
  const symbol = "TOPG";

  const args = [
    initialSupply,
    name,
    symbol,
  ];

  const TopGToken = await deploy('TopGToken', {
    from: deployer,
    args,
    log: true,
    waitConfirmations: currentNetwork.blockConfirmations,
  });

  if(!isLocal){
    await verify(TopGToken.address, args);
  }

  log('-------------------------------------------------')
}

module.exports.tags = ['all', 'topgtoken'];

the verify file:

const { run } = require('hardhat');

async function verify(contractAddress, args) {
  try {
    await run("verify:verify", {
    address: contractAddress,
    constructorArguments: args,
    });
  } catch (error) {
    console.error(error)
  }
}

module.exports = {
  verify
};

1 Answer 1

1

Hardhat found multiple contracts in the project (your TopGTOken and the imported ERC20), and it doesn't know against which one you want to verify the bytecode.

You need to specify your contract.

async function verify(contractAddress, args) {
  try {
    await run("verify:verify", {
    address: contractAddress,
    constructorArguments: args,
    contract: "contracts/TopGToken.sol"
    });
  } catch (error) {
    console.error(error)
  }
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.