Lesson 7: TypeError: Cannot read properties of undefined (reading 'ethUsdPriceFeed') #2516
-
This is the error I am getting, else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
} I will attach the entire code here // import
// main function
// calling main function
const { network } = require("hardhat")
// async function deployFunc() {
// console.log("Hi!")
// }
// module.exports.default = deployFunc
// const helperConfig = require("../helper-......")
// const networkConfig = helperConfig.networkConfig
const { networkConfig, developmentChains } = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")
module.exports = async ({ getNamedAccounts, deployments }) => {
//const { getNamedAccounts, deployments } = hre
// hre.getNamedAccounts
// hre.deployments
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
// if chainId is X use address Y
// if chainId is Z use address A
// const ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
let ethUsdPriceFeedAddress
if (developmentChains.includes(network.name)) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
ethUsdPriceFeedAddress = ethUsdAggregator.address
} else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
}
// if the contract doesn't exist, we deploy a minimal version of
// for out local testing
// well what happens when we want to change chains?
// when going for localhost or hardhat network we want to use a mock
log("---------------------------------------------------------")
log("Deploying FundMe and waiting for confirmation...")
const args = [ethUsdPriceFeedAddress]
const fundMe = await deploy("FundMe", {
from: deployer,
args: args, // put price feed address
log: true,
waitConfirmations: network.config.blockConfirmation || 1,
})
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
await verify(fundMe.address, args)
}
log("-------------------------------------------------------------")
}
module.exports.tags = ["all", "fundme"] I have tried my best to solve it but I can not figure it out... Also i saw this error in other dicussions but none were able to help me with mine.... thank you in advance for helping me out |
Beta Was this translation helpful? Give feedback.
Answered by
othaime-en
Sep 12, 2022
Replies: 1 comment 12 replies
-
Hey @JuniorSua please share your helper-hardhat-config.js file. |
Beta Was this translation helpful? Give feedback.
12 replies
Answer selected by
JuniorSua
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @JuniorSua please share your helper-hardhat-config.js file.