Abhishek Yadav
Abhishek Yadav

Reputation: 21

NomicLabsHardhatPluginError: The constructor for contracts/FundMe.sol:FundMe has 1 parameters but 0 arguments were provided instead at encodeArgument

This is the error I'm getting.

I tried It without verifying on etherscan it still gave the same error I am deploying it on the goerli network Pls have a look at that pls

yarn run v1.22.15
warning ..\package.json: No license field
$ "E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\.bin\hardhat" deploy --tags all --network goerli
Nothing to compile
5
ethUsdPriceFeedAddress 0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e
reusing "FundMe" at 0x6DD6B9f3bD775549Ef0e6423C49c9d03AC6bb778
Verifying Contracts.........
Nothing to compile
NomicLabsHardhatPluginError: The constructor for contracts/FundMe.sol:FundMe has 1 parameters
but 0 arguments were provided instead.
    at encodeArguments (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@nomiclabs\hardhat-etherscan\src\ABIEncoder.ts:29:13)
    at SimpleTaskDefinition.verifySubtask [as action] (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@nomiclabs\hardhat-etherscan\src\index.ts:283:34)
    at Environment._runTaskDefinition (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)
    at Environment.run (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:14)
    at verify (E:\Block Chain Projects\FUND_ME_FULLSTACK\utils\verify.js:6:9)
    at Object.module.exports [as func] (E:\Block Chain Projects\FUND_ME_FULLSTACK\deploy\01_fudme_deploy.js:31:9)
    at DeploymentsManager.executeDeployScripts (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1219:22)
    at DeploymentsManager.runDeploy (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1052:5)
    at SimpleTaskDefinition.action (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat-deploy\src\index.ts:438:5)
    at Environment._runTaskDefinition (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)

    Caused by: Error: types/values length mismatch (count={"types":1,"values":0}, value={"types":[{"name":"priceFeed","type":"address","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"address","_isParamType":true}],"values":[]}, code=INVALID_ARGUMENT, version=abi/5.7.0)        at Logger.makeError (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)
        at Logger.throwError (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)
        at AbiCoder.encode (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@ethersproject\abi\src.ts\abi-coder.ts:101:20)
        at Interface._encodeParams (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@ethersproject\abi\src.ts\interface.ts:323:31)
        at Interface.encodeDeploy (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@ethersproject\abi\src.ts\interface.ts:327:21)
        at encodeArguments (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@nomiclabs\hardhat-etherscan\src\ABIEncoder.ts:22:8)
        at SimpleTaskDefinition.verifySubtask [as action] (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\@nomiclabs\hardhat-etherscan\src\index.ts:283:34)
        at Environment._runTaskDefinition (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)
        at Environment.run (E:\Block Chain Projects\FUND_ME_FULLSTACK\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:14)
        at verify (E:\Block Chain Projects\FUND_ME_FULLSTACK\utils\verify.js:6:9)

MY 00_fundme_deploy.js I am trying to deploy a crowd funding project Its got deployed correctly on hardhat localhost network but it throws error on goerli network

const {networkconfig,developmentChains} = require("../helper-hardhat-config")
const {getNamedAccounts,deployments,network} = require("hardhat");
const {verify} = require("../utils/verify.js");
require("dotenv").config();
    module.exports = async ({getNamedAccounts,deployments}) =>{
    const {deploy,log} = deployments;
    const {deployer}= await  getNamedAccounts();
    const chainID = network.config.chainId;
    console.log(chainID)

    //IF chain ID is A then use address B
    // IF CHAINID IS Z THEN USE C
    let ethUsdPriceFeedAddress
    if (chainID == 31337) {
        const ethUsdAggregator = await deployments.get("MockV3Aggregator")
        ethUsdPriceFeedAddress = ethUsdAggregator.address
    } else {
        ethUsdPriceFeedAddress = networkconfig[chainID]["ethUsdPriceFeed"]
    }
    // if the Price feed contract doesnt't exists then we deploy a 
    //minimal version of our testing
    console.log("ethUsdPriceFeedAddress",ethUsdPriceFeedAddress)
    // deploy on the another network 
    const fundme = await deploy("FundMe",{
        from:deployer,
        args: [ethUsdPriceFeedAddress],
        log:true,
        waitconfirmations:network.config.blockConfirmations  || 1,
    })
    if(!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY){
        await verify(fundme.address, [ethUsdPriceFeedAddress])
    }
    log("------------------------------------------");
}
module.exports.tags = ["fund","all"];

Constructor Function of FundMe.sol

constructor(address priceFeed) {
        s_priceFeed = AggregatorV3Interface(priceFeed);
        i_owner = msg.sender;
    }

It takes one arguments (Pricefeed)

Upvotes: 0

Views: 1750

Answers (4)

Dmytro Burzak
Dmytro Burzak

Reputation: 1

Check out your verify.js. Most likely, you are not reading and passing the arguments into the verify script code

Upvotes: 0

Alphard1188118
Alphard1188118

Reputation: 1

yarn hardhat verify --network goerli 0x6DD6B9f3bD775549Ef0e6423C49c9d03AC6bb778 0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e

Try this if this work for you?

Upvotes: 0

azeez okhamena
azeez okhamena

Reputation: 1

use this instead for javascript users if you can convert to typescript

const { run } = require("hardhat")

const verify = async function verify(contractAdress, args) {
    console.log("verifying contract !!!!!!!")

    try {
        await run("verify:verify", {
            address: contractAdress,
            constructorArguments: args,
        })
    } catch (e) {
        if (e.message.toLowerCase().includes("already verified")) {
            console.log("already verified")
        } else {
            console.log(e)
        }
    }
}

module.exports = {
    verify,
} 

I had that same issue now I had to equate the function to the variable verify, then export it from the module.exports

Upvotes: 0

Ryan Gannon
Ryan Gannon

Reputation: 53

Your issue isn't with the deployment, but its with the verification, correct? If so, I think this may help as I've just encountered the same error ...

Check your verify.js script. This is what mine looked like when I had the error (verify.ts):

import { run } from "hardhat"

async function verify(address: string, args: any) {
  console.log("Verifying contract...")
  try {
    await run("verify:verify", {
      address: address,
      constructorArgs: args <-- THIS WAS THE ISSUE -->
    })
  } catch (error: any) {
    if (error.message.toLowerCase().includes("already verified")) {
      console.log("Already verified")
    } else {
      console.error(error)
    }
  }
}

export default verify

And I changed it to this:

import { run } from "hardhat"

async function verify(address: string, args: any) {
  console.log("Verifying contract...")
  try {
    await run("verify:verify", {
      address: address,
      constructorArguments: args <-- THIS WAS THE ISSUE -->
    })
  } catch (error: any) {
    if (error.message.toLowerCase().includes("already verified")) {
      console.log("Already verified")
    } else {
      console.error(error)
    }
  }
}

export default verify

I believe it was an autocomplete error!

Upvotes: 4

Related Questions