0
Error: ERROR processing /home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/deploy/01-deploy-fund-me.js:
TypeError: Cannot read properties of undefined (reading '5')
    at Object.module.exports [as func] (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/deploy/01-deploy-fund-me.js:27:47)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at DeploymentsManager.executeDeployScripts (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1219:22)
    at DeploymentsManager.runDeploy (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1052:5)
    at SimpleTaskDefinition.action (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/index.ts:438:5)
    at Environment._runTaskDefinition (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:308:14)
    at Environment.run (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:156:14)
    at SimpleTaskDefinition.action (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/index.ts:584:32)
    at Environment._runTaskDefinition (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:308:14)
    at Environment.run (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:156:14)
    at DeploymentsManager.executeDeployScripts (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1222:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at DeploymentsManager.runDeploy (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1052:5)
    at SimpleTaskDefinition.action (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/index.ts:438:5)
    at Environment._runTaskDefinition (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:308:14)
    at Environment.run (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:156:14)
    at SimpleTaskDefinition.action (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/index.ts:584:32)
    at Environment._runTaskDefinition (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:308:14)
    at Environment.run (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:156:14)
    at SimpleTaskDefinition.action (/home/surajsahoo/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/index.ts:669:5)
error Command failed with exit code 1.

Above mentioned error is coming while deploying. Below provided is the js file 01-deploy-fund-me.js

const { networkConfig } = require("../helper-hardhat-config")
const { network } = require("hardhat")
const { verify } = require("../utils/verify")

module.exports = async ({ getNamedAccounts, deployments }) => {
    const { deploy, log } = deployments
    const { deployer } = await getNamedAccounts()
    const chainId = network.config.chainId

    //const ethUsdPriceFeedAddress = networkConfig[chainId]["ethusdpricefeed"]
    let ethUsdPriceFeedAddress
    if (chainId == "31337") {
        const ethUsdAggregator = await deployments.get("MockV3Aggregator")
        ethUsdPriceFeedAddress = ethUsdAggregator.address
    } else {
        ethUsdPriceFeedAddress = networkConfig[chainId]["ethusdpricefeed"]
    }

    const fundMe = await deploy("FundMe", {
        from: deployer,
        args: [ethUsdPriceFeedAddress], //put price feed address
        log: true,
        waitConfirmations: network.config.blockConfirmations || 1,
    })

    //     if (!developmentChains.includes(network.name)) {
    //         await verify(fundMe.address, [ethUsdPriceFeedAddress])
    //     }
}

module.exports.tags = ["all", "fundme"]

Below mentioned is the helper-hardhat-config file

const networkConfig = {
    31337: {
        name: "localhost",
    },
    5: {
        name: "goerli",
        ethusdpricefeed: "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e",
    },
}
const developmentChain = ["hardhat", "localhost"]

module.export = {
    networkConfig,
    developmentChain,
}
2
  • 1
    can you post your networkConfig var from the helper-hardhat-config file?
    – immaxkent
    Commented Jan 3, 2023 at 10:07
  • I have added the helper-hardhat-config file in the question Commented Jan 4, 2023 at 4:36

1 Answer 1

0

It seems you are running code from here https://github.com/PatrickAlphaC/hardhat-fund-me-fcc

I had checked out it and run, it works well.

From the error message, error happened at deploy/01-deploy-fund-me.js line 27, even line number is missing in your post, but I can guess that issue code is atethUsdPriceFeedAddress = networkConfig[chainId]["ethusdpricefeed"], and chain id is 5, according to TypeError: Cannot read properties of undefined (reading '5'), that means networkConfig is undefined.

I noticed that some variables are in lower case (like 'ethusdpricefeed') in your post, but in the original repository they are camel-style(like 'ethUsdPriceFeed'). Compare your code with original repository to find out differences.

1
  • Thank you so much. The problem was with the helper-hardhat-config file. It should be "module.exports" and not "module.export" Commented Jan 4, 2023 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.