PatrickAlphaC / hardhat-fund-me-fcc

82 stars 183 forks source link

Error while yarn hardhat deploy --network rinkeby #70

Closed olekmorawski closed 2 years ago

olekmorawski commented 2 years ago

Hello im following the course and i got stuck. Up to this point ive been problem-solving on my own but here i have hit a wall. I want to do - yarn hardhat deploy --network rinkeby but i get an error like this :

Nothing to compile
An unexpected error occurred:

Error: ERROR processing C:\Users\Hardhat\hardhat-fund-me\deploy\01-deploy-fund-me.js:16:47
TypeError: Cannot read properties of undefined (reading '4')
    at Object.module.exports [as func]

My deploy script looks like this:

const { network } = require("hardhat")
const { networkConfig, devChains } = require("../helper-hardhat-config")
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 (devChains.includes(network.name)) {
        const ethUsdAggregator = await deployments.get("MockV3Aggregator")
        ethUsdPriceFeedAddress = ethUsdAggregator.address
    } else {
        ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
    }

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

    if(!devChains.includes(network.name) && process.env.ETHERSCAN_API_KEY){
        await verify(fundMe.address.args)
    }

    log("==================================================")
}
module.exports.tags = ["all", "fundme"]

the only thing that can be "read as 4" in this file - cause this is the error is the chainId pulled from the helper so this is my helper:

const networkCofig = {
    4: {
        name: "rinkeby",
        ethUsdPriceFeed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e",
    },
}

const devChains = ["hardhat", "localhost"]
const DECIMALS = 8
const INITIAL_ANSWER = 200000000

module.exports = { networkCofig, devChains, DECIMALS, INITIAL_ANSWER }

Can someone explain what is wrong here?

olekmorawski commented 2 years ago

Never mind - a typo lol - closed!