【发布时间】:2022-09-24 13:51:57
【问题描述】:
这是我得到的错误。
我在没有验证 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我正在尝试部署一个众筹项目它已正确部署在安全帽 localhost 网络上,但它在 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)
-
由于某种原因
args: [ethUsdPriceFeedAddress],ethUsdPriceFeedAddress未定义在哪里。做了这个日志console.log(\"ethUsdPriceFeedAddress\",ethUsdPriceFeedAddress) -
我推测当它是非本地安全帽环境时,例如chainId !== 31337 它在 else 中赋值,networkconfig 拼写错误应该是 networkConfig。或 network.config.chainId 返回的链 ID 是字符串,在您的配置中它的类型为 number,反之亦然。
标签: node.js solidity yarnpkg hardhat