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