我收到的错误(在部署时,请参阅代码末尾)
Error: ERROR processing skip func of /home/amey/hardhat/hardhat-fund-me/deploy/01-deploy-fund-me.js:
TypeError: Cannot read properties of undefined (reading 'ethUsdPriceFeed')
当我点击错误时,我会看到01-deploy-fund-me.js(在另一个文件中)中的这一行
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
这是我试图部署的代码
const { network, getNamedAccounts, deployments } = require("hardhat")
const {
developmentChains,
DECIMALS,
INITIAL_ANSWER,
} = require("../helper-hardhat-config")
module.exports = async ({ getNamedAccounts, deployment }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
if (developmentChains.includes(network.name)) {
log("Local network detected! Deploying mocks...")
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: (DECIMALS, INITIAL_ANSWER),
})
log("Mocks Deployed!")
log("--------------------------------------------------------------")
}
}
module.exports.tags = ["all", "mocks"]
谢谢。
我也遇到了同样的问题。我的问题的解决方案是添加:
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
1: 0 // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
}
}
至硬盘底部。图.ts
来源:https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/blob/main/hardhat.config.js
我也遇到了同样的问题。如果您使用console.log()注销部署程序变量,它将返回空值。这意味着getNamedAccounts无法解析帐户。但是,如果使用mock,部署程序变量会返回一个帐号。如果您在hardhat.config.js文件中使用元任务帐户no硬编码部署程序变量。它将返回一个未知的签名者错误。我仍然被困在这个问题上。
您之所以出现此错误,是因为您缺少一个重要的安全帽依赖项"安全帽华夫饼";尝试
npm install --save-dev @nomiclabs/hardhat-waffle
在hardhat.config.js中添加
require("@nomiclabs/hardhat-waffle");
这应该有效!
在您的网络中配置属性"ethUsdPriceFeed";定义。试着像下面的一样定义它
export const networkConfig :networkConfigType= {
4: {
name: "rinkeby",
ethUsdPriceFeed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e",
},
137: {
name: "polygon",
ethUsdPriceFeed: "0xF9680D99D6C9589e2a93a78A04A279e509205945",
},
};