PatrickAlphaC / hardhat-fund-me-fcc

82 stars 184 forks source link

fundme contract not verifying after deployment on etherscan (tried both -> auto and manually) #39

Closed RohitKS7 closed 2 years ago

RohitKS7 commented 2 years ago

Fundme contract not verifying after deployment on etherscan i had tried both ways automatic and manually.

Showing this error in terminal :-

Error in plugin @nomiclabs/hardhat-etherscan: The constructor for contracts/FundMe.sol:FundMe has 1 parameters but 0 arguments were provided instead

01-deploy-fundme.js

const { isAddress } = require("ethers/lib/utils");
const { networkConfig } = require("../helper-hardhat-config");
const { network } = require("hardhat");
const { verify } = require("../utils/verify");

module.exports = async ({ getNamedAccounts, deployments }) => {
  const { deploy, log, get } = deployments;
  const { deployer } = await getNamedAccounts();
  const chainId = network.config.chainId;

  let ethUsdPriceFeedAddress;
  if (chainId == 31337) {
    const ethUsdAggregator = await get("MockV3Aggregator");
    ethUsdPriceFeedAddress = ethUsdAggregator.address;
  } else {
    ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"];
  }

  const fundme = await deploy("FundMe", {
    from: deployer,
    args: [ethUsdPriceFeedAddress], 
    log: true,
    waitConfirmations: network.config.blockConfirmations || 1, 
  });

  if (chainId !== 31337 && process.env.ETHERSCAN_API_KEY) {
    await verify(fundme.address, [ethUsdPriceFeedAddress]);
  }
  log("------------------------------------------");
};

module.exports.tags = ["all", "fundme"];

verify.js

const { run } = require("hardhat");

const verify = async (contractAddress, args) => {
  console.log("Verifying contract...");

  try {
    await run("verify:verify", {
      address: contractAddress,
      construtorArguments: args,
    });
  } catch (e) {
    if (e.message.toLowerCase().includes("already verified")) {
      console.log("Already verified!!");
    } else {
      console.log(e);
    }
  }
};

module.exports = { verify };

and I double checked .env and hardhat.config, they are same what patrick had done in video

willfintech commented 2 years ago

It might be a network issue. I experienced a similar issue 2 days ago. But it worked today with the same code. You can try it a few days later. I will look at the code in detail again.

PatrickAlphaC commented 2 years ago

Closing, likely an issue with your ethUsdPriceFeedAddress. Can you please ask questions on the discussions tab of https://github.com/smartcontractkit/full-blockchain-solidity-course-js/?

Thank you.