How to verify a contract on Etherscan/BscScan/PolygonScan

I encountered some issues with contract verification on Polygonscan, for a customizable ERC20 token factory that imports OpenZeppelin's ERC20. Here's a summary of what I found: Contract Verification on PolygonScan - #7 by juwu

I stopped having problems checking contracts when I started using complex argument checking:

There may also be verification issues if using windows Powershell with the / symbol turning it to \
causing the verification to fail.

I recommend that you use complex verification.


I'm using Hardhat and trying to verify contracts on TESTNET Fantom (FTM) Blockchain Explorer ( So far I've been unsuccessful. Weirdly enough I had no issues verifying my contract on Rinkeby with a similar setup. Here's my setup

networks: {
    fantom: {
      url: '',
      accounts: [`${process.env.METAMASK_KEY}`]
    rinkeby: {
      url: `${process.env.RINKEBY_API_KEY}`,
      accounts: [`${process.env.METAMASK_KEY}`]
  etherscan: {
    apiKey: {
      ftmTestnet: process.env.FTMSCAN_API_KEY,
      rinkeby: process.env.ETHERSCAN_API_KEY,

I run:

npx hardhat verify --constructor-args scripts/args.ts 0x00000000000000000000000000000000000000000 --network fantom

and get this:

Successfully submitted source code for contract
contracts/Greeter.sol:Greeter at 0x0000000000000000000000000000000000000000
for verification on the block explorer. Waiting for verification result...

We tried verifying your contract Greeter without including any unrelated one, but it failed.
Trying again with the full solc input used to compile and deploy it.
This means that unrelated contracts may be displayed on Etherscan...

Successfully submitted source code for contract
contracts/Greeter.sol:Greeter at 0x0000000000000000000000000000000000000000
for verification on the block explorer. Waiting for verification result...

Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed.
Reason: Fail - Unable to verify

For more info run Hardhat with --show-stack-traces```

Figured this one out on - the ftm testnet is faulty and currently has issues with contract approval.


I keep getting the same byte code error while I am trying to verify a smart contract , I know how to do it perfectly & I tried the same contract to get it verified through test net it works there perfectly but when I try to verify it on main net it keeps getting byte code errors here like the others posted which is really weird.

Did you check if you're passing the constructor parameters correctly?

Hello I'm experiencing this issue:

So this is the smart contract that i'm trying to verify.

I've choose to use SingleFile and use Flatten tool in remix to get my single file contract.

Then for constructor args I'm using and my constructor args are:
uint256 - 1642081492, uint256 - 8760, uint256 - 60000000000000000, string -ipfs://QmURMg8CQrBHjn2jPrZgX5fYj9h26f7pzna6PxGPQB8cqp/{id}.json, string Suntur - 8760 hours, string 1B1ST1, address - 0x1b4fbfb1fd99d00128afeb4dc25fc1d6608b1134, address[] - ["0x12cCcE08EE9CDaA564ae6B025a21E01e75948a81", "0xdeE12Ff8f1f2aa5b3ba5E7ba68d0033Fc08C6b28", "0xa9B37C8eeAAd39fd914aC63d6887241a916a45fc"], uint256[] - [40, 30, 30]

Optimizer off, and still hitting this error no idea how to verify it :frowning:

Hello, how to trigger verification process from frontend?
This tutorial only shows how to do it on console...
Is there any way to do it with Javascript?

You can use the Etherscan API to verify a contract. This is out of scope of the guide here, please refer to Etherscan's documentation:

Hello I'm using the Hardhat plugin for contract verification.

Is there a way to set the network for verification in the verify:verify substack?
I am trying to run verification through a script and I need to set the network outside of the cli.

Please see my verify:verify function:

async function verifyArtifacts(contractName: string, contractAddress: string, constructorArgs: any[]) {
    console.log(`${contractName}: ${contractAddress}`)

    await"verify:verify", {
       address: contractAddress,
       constructorArguments: constructorArgs,

    console.log(`${contractName}: ${contractAddress}`, "has been verified.")

I am trying to verify my contracts on the ropsten network.

In hardhat.config.ts I have set my api key this way:

    etherscan: {
        apiKey: process.env.ETHERSCAN_API_KEY,

and have ropsten in networks:

networks: {
        mainnet: createMainnetConfig(),
        hardhat: createHardhatConfig(),
        goerli: createTestnetConfig("goerli"),
        kovan: createTestnetConfig("kovan"),
        rinkeby: createTestnetConfig("rinkeby"),
        ropsten: createTestnetConfig("ropsten"),
        localhost: {
            accounts: {
            chainId: chainIds.hardhat,
            gasMultiplier: 10,
    const url = `https://eth-${network}${alchemyApiKey}`;
    return {
        accounts: {
            count: 10,
            initialIndex: 0,
            path: "m/44'/60'/0'/0", // HD derivation path
        chainId: chainIds[network],
        gas: 500000

Thank you for any insight!

@MaD From looking at the hardhat-etherscan code, verify:verify calls verify:get-etherscan-endpoint, which is defined here. Maybe you can try overriding that similar to what is done in this test. Otherwise, it would be better to contact the Hardhat team for support with this use case.

1 Like


I greate token with openzeppelin and remix

my smart contract is default

"// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

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

contract Pixecoin is ERC20 {
constructor() ERC20("Pixecoin", "PIXE") {
_mint(msg.sender, 99999999 * 10 ** decimals());

i want to publish my token on bscscan, what file need to upload and where this file to get ?
Thanks. Do i need to use Single file or Multi part files on bsc ?

So have you followed the tutorial shared above? I think it can solve 99.99% of the problems.

1 Like

Some one can explain why this error showing
I am newbie on solidity . trying to create NFT contract . I ve able to hardhat compile and deploy contract .

enter image description here

however during verify my contract with arguments and I am getting this error:

Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed. Reason: Fail - Unable to verify

Before this verify erc20 is not showing any problem but when I apply for erc721 it showing this error

Hi, welcome to the community! :wave:

Maybe it is not the source code.


I keep getting the error below when I try to verify on BscScan, any ideas?

ParserError: Expected string literal (path), "*" or alias list.
--> myc:7:8:
7 | import "
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Hi, welcome to the community! :wave:

I think you should use the source file rather than the reference file.

1 Like

Hi, sorry for the dumb question, but what do you mean by that?

You can flatten all contracts into a single file or load multi contracts to verify, just do not use a dependency like import " to verify.

Load the source code of this dependency, and of course, you can always use plugin to verify contracts, it is relllllly convenient.

1 Like