Search code examples
javascriptethereumsoliditysmartcontracts

TypeError: Cannot read properties of undefined AND Error: ERROR processing skip func


The error(s) I'm getting (while deploying, see end for code)

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')

When I click on the error, i'm taken to this line in 01-deploy-fund-me.js (in another file)

ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]

here is the code i was trying to deploy

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"]

Thank You.


Solution

  • I was having the same issue. The solution to my problem was adding:

    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
        }
    }
    

    To the bottom of hardhat.config.ts

    Source: https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/blob/main/hardhat.config.js