Verify ERC20 Contract Using Hard Hat

I have tried for hours to verify my contract. I've tried everything. That last option I have is hard hat. Im trying to compile the same code I compiled in remix just fine but i get this error "

Error HH404: File ../ERC20.sol, imported from contracts/EggplantInu.sol, not found.

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

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

contract MyToken is ERC20 {
    constructor() ERC20("Eggplant Inu", "EGGP") {
        _mint(msg.sender, 99000000000000 * 10 ** decimals());
    }
}

trying to follow these instructions but its way over my head a brand new dev https://snowtrace.io/documentation/recipes/hardhat-verification

Your help would be GREATLY appreciated!!!

See How to verify a contract on Etherscan/BscScan/PolygonScan.

2 Likes

This was a HUGE help.. I feel SOO close, but the post that post leads to is a bit older and unfortunately the "flattener" plugin in remix is not coming up for me? Is there another extension you maay know or alternate method to flatten the file? I tried manually by putting the contract you sent and all imports into one file but that throws a ton of errors. thank you again!

Alright, i got the file flattened!! how simple it was in the end. hah. Ok, so now I have the flattened contract it compiled alright, but the post here is a bit out of date again, at least for snowtrace because when i try to click the verify contract button there it takes me to the hard hat method for verifying a contract here https://snowtrace dot io/documentation/recipes/hardhat-verification

Go to snowtrace official documentation webpage, scroll down to the Verify Source Code section, and follow the steps listed in there.

In general, you only need to reconfigure the URL below with your specific parameters:

https://api.routescan.io/v2/network/mainnet/evm/1/etherscan/api
?module=contract
&action=verifysourcecode
&contractaddress=...
&sourceCode=...
&codeformat=solidity-single-file
&contractname=...
&compilerversion=...
&optimizationUsed=...
&runs=...
&licenseType=1
&apikey=...
1 Like