Error verifying contract on FTMScan

Hello,

I'm using Hardhat + hardhat-etherscan and trying to verify the contract on FTMScan.
My Hardhat config looks like this:

import { HardhatUserConfig } from "hardhat/types";
import "@nomiclabs/hardhat-waffle";
import "hardhat-deploy-fake-erc20";
import "@nomiclabs/hardhat-etherscan";
import  "dotenv/config";

const config: HardhatUserConfig = {
  solidity: {
    compilers: [{ version: "0.8.7", settings: {} }],
  },

  networks: {
    fantom: {
      url: 'https://rpc.testnet.fantom.network/',
      accounts: [`${process.env.METAMASK_KEY}`]
    },
    rinkeby: {
      url: `https://eth-rinkeby.alchemyapi.io/v2/${process.env.RINKEBY_API_KEY}`,
      accounts: [`${process.env.METAMASK_KEY}`]
    }
  },
  etherscan: {
    apiKey: {
      ftmTestnet: process.env.FTMSCAN_API_KEY,
      rinkeby: process.env.ETHERSCAN_API_KEY,
    }
  },
};

export default config;

I'm using the Greeter.sol for testing

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
contract Greeter {
    string private greeting;

    constructor(string memory _greeting) {
        console.log("Deploying a Greeter with greeting:", _greeting);
        greeting = _greeting;
    }
    function greet() public view returns (string memory) {
        return greeting;
    }
    function setGreeting(string memory _greeting) public {
        console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
        greeting = _greeting;
    }
}

Deploy.ts looks like this:

import { ethers } from "hardhat";

async function main() {
  const [deployer] = await ethers.getSigners();
  const hre = require("hardhat");

  console.log(`Deploying contracts with the account: ${deployer.address}`);
  const balance = await deployer.getBalance();
  console.log(`Account balance: ${balance.toString()}`);

  const Greeter = await ethers.getContractFactory("Greeter");
  const greeter = await Based.deploy('HELLO!');
  await based.deployed();

  console.log(`Token address: ${based.address}`);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

I have an args.ts file to pass my variables to etherscan.

And I use this command:

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

I always get this log with an error at the end

Successfully submitted source code for contract
contracts/Greeter.sol:Greeter at 0x00000000000000000000000000000000000000000
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 0x00000000000000000000000000000000000000000
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

The weird thing here is that this setup works perfectly with Rinkeby and all contracts get verified no problem.

Any advice or suggestion is welcomed.

Thank you

It looks like you're trying to verify a contract at address 0x00000000000000000000000000000000000000000. You need to put your contract address in there.

Hi Mate,
I've encountered the very situation. It seems Fantom network does not support Hardhat Etherscan Verification at the moment.

Things work well in Ethereum Testnet. I've mentioned this problem to Fantom Support but still got no response.

Same here - trying identical code on other networks - all good, Fantom - fails to verify:

Compiling your contract excluding unrelated contracts did not produce identical bytecode.
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/OGS/OGSPPool.sol:OGSPPool at 0x4A7ed772b39A248acFf3f529e74c31fAAc4ab7AD
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

1 Like

We do support Hardhat Etherscan Verification.

For verification of smart contract on Fantom, please refer to this guide:

For verification, please make sure the constructor arguments are matched.

For more assistance, please contact Fantom support team.

1 Like