Error with Hardhat when verifying a ERC20 smart contract deployed with Remix

Hi. I am trying to verify the following smart contract using Hardhat (it was deployed by another account with remix, on the Ethereum Mainnet):

:1234: Code to reproduce

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

contract Genetix is ERC20 {

    string private _name = "GENETIX";
    string private _symbol = "GNTX";

    uint256 private _totalSupply = 1978651800 * 10 ** 18;

    constructor() ERC20(_name, _symbol) {

        _mint(msg.sender, _totalSupply);


    function burn(uint256 _amount) public {
        require(balanceOf(msg.sender) >= _amount, "Not Enough Tokens To Burn.");

        _burn(msg.sender, _amount);


:computer: Environment

Deployed using Remix, Solidity Compiler v. 0.8.7, and tried to verify it with Hardhat v. 2.8.3.

My hardhat.config.js file:


let secrets = require("./secrets");

// This is a sample Hardhat task. To learn how to create your own go to
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();

  for (const account of accounts) {

// You need to export an object to set up your config
// Go to to learn more

 * @type import('hardhat/config').HardhatUserConfig
module.exports = {
  solidity: "0.8.7",
  networks: {
    rinkeby: {
      url: secrets.url,
      accounts: [secrets.key]
  etherscan: {
    apiKey: "secrets.apiKey"

Any solutions out there? My token contract address is "0x703a2B537367cc8eA3360A54B842692462Bb9969". Thank you.

Solved using remix Flattener plugin and via etherscan verification. Anyways, do anyone know why it threw me an error when trying to verify it through hardhat?

1 Like

Hi, welcome! :wave:

Glad to hear you have solved your problems.

Not sure for this, I always use the hardhat to verify contracts, and it can work correctly as expected.

Solidity compilation is sensitive to details sometimes. If you didn't deploy it originally from Hardhat, maybe it wasn't able to match the bytecode.