这是我遇到的错误。
我尝试了它,但没有在 etherscan 上进行验证,它仍然给出了相同的错误,我正在将它部署在 goerli 网络上,请看一下
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)
我的00_fundme_deploy.js 我正在尝试部署一个众筹项目,它已在 Hardhat 本地主机网络上正确部署,但在 goerli 网络上抛出错误
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"];
FundMe.sol的构造函数
constructor(address priceFeed) {
s_priceFeed = AggregatorV3Interface(priceFeed);
i_owner = msg.sender;
}
它需要一个参数(Pricefeed)
您的问题不在于部署,而在于验证,对吗?如果是这样,我认为这可能会有所帮助,因为我刚刚遇到了同样的错误......
检查您的
verify.js
脚本。这就是我出现错误时的样子(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
我把它改成这样:
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
我相信这是一个自动完成错误!
如果您可以转换为打字稿,请为 javascript 用户使用此功能
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,
}
我现在遇到了同样的问题,我必须将该函数等同于变量 verify,然后从 module.exports 中导出它
yarn hardhat verify --network goerli 0x6DD6B9f3bD775549Ef0e6423C49c9d03AC6bb778 0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e
如果这对您有用,请尝试一下?
检查您的
verify.js
。最有可能的是,您没有读取参数并将其传递到 verify
脚本代码