0
PS C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project> npx hardhat deploy --network sepolia
Nothing to compile
An unexpected error occurred:

Error: ERROR processing C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\deploy\01-deploy-fundme.js:
TypeError: Cannot read properties of undefined (reading '11155111')
    at Object.module.exports [as func] (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\deploy\01-deploy-fundme.js:19:47)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at DeploymentsManager.executeDeployScripts (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1222:22)
    at DeploymentsManager.runDeploy (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1055:5)
    at SimpleTaskDefinition.action (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\index.ts:438:5)
    at Environment._runTaskDefinition (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat\src\internal\core\runtime-environment.ts:330:14)
    at Environment.run (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat\src\internal\core\runtime-environment.ts:163:14)
    at SimpleTaskDefinition.action (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\index.ts:584:32)
    at Environment._runTaskDefinition (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat\src\internal\core\runtime-environment.ts:330:14)
    at Environment.run (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat\src\internal\core\runtime-environment.ts:163:14)
    at DeploymentsManager.executeDeployScripts (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1225:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at DeploymentsManager.runDeploy (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1055:5)
    at SimpleTaskDefinition.action (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\index.ts:438:5)
    at Environment._runTaskDefinition (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat\src\internal\core\runtime-environment.ts:330:14)
    at Environment.run (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat\src\internal\core\runtime-environment.ts:163:14)
    at SimpleTaskDefinition.action (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\index.ts:584:32)
    at Environment._runTaskDefinition (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat\src\internal\core\runtime-environment.ts:330:14)
    at Environment.run (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat\src\internal\core\runtime-environment.ts:163:14)
    at SimpleTaskDefinition.action (C:\Users\BISHOP\Desktop\blockchain_fcc\hardhat-fundme-project\node_modules\hardhat-deploy\src\index.ts:669:5)

Above mentioned error is coming while deploying to sepolia testnet. Below provided is the file 01-deploy-fundme.js

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


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

    let ethUsdPriceFeedAddress
    //Should use a mock when going for localhost network or hardhat
    if (chainId === 31337) {
        const ethUsdAggregator = await deployments.get("MockV3Aggregator")
        ethUsdPriceFeedAddress = ethUsdAggregator.address
    } else {
        ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
    }

    const args = [ethUsdPriceFeedAddress]
    log("Deploying Fundme contract and waiting for confirmations...")
    const fundMe = await deploy("FundMe", {
        from: deployer,
        args: args, //The Price Feed Address is to enter the constructor in the contract.
        log: true,
        waitConfirmations: network.config.blockConfirmations || 1,
    })
    log(`Fudme contracts deployed at: ${fundMe.address}`)
    log("___________________________________________")

    // await verify(fundMe.address, args)

    if (!chainId == 31337 && process.env.ETHERSCAN_API_KEY) {
        await verify(fundMe.address, args)
    }
}

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

Below is the helper-hardhat-config.js

const networkConfig = {
    31337: {
        name: "localhost"
    },
    11155111: {
        name: "sepolia",
        ethUsdPriceFeed: "0x694AA1769357215DE4FAC081bf1f309aDC325306",
    },
    // 137: {
    //     name: "mumbai", //Polygon Testnet
    //     ethUsdPriceFeed: "0x0715A7794a1dc8e42615F059dD6e406A6594651A",
    // },
}
const developmentChains = ["hardhat", "localhost"]


module.export = {
    networkConfig,
    developmentChains,
}

Below is the hardhat-config.js

require("@nomicfoundation/hardhat-toolbox")
require("dotenv").config()
require("@nomiclabs/hardhat-etherscan")
require("hardhat-gas-reporter")
require("solidity-coverage")
require("hardhat-deploy")
require("@nomiclabs/hardhat-ethers")


/** @type import('hardhat/config').HardhatUserConfig */

const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || ""
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY

module.exports = {
    solidity: {
        compilers: [{ version: "0.8.18" }, { version: "0.6.6" }],
    },
    defaultNetwork: "hardhat",
    networks: {
        sepolia: {
            url: SEPOLIA_RPC_URL,
            accounts: [PRIVATE_KEY],
            chainId: 11155111,
            blockConfirmations: 6,
        },
        localhost: {
            url: "http://127.0.0.1:8545/",
            chainId: 31337,
        },
    },
    etherscan: {
        apiKey: {
            sepolia: ETHERSCAN_API_KEY,
        },
    },
    gasReporter: {
        enabled: false,
        outputFile: "gas-report.txt",
        noColors: true,
        currency: "USD",
        coinmarketcap: COINMARKETCAP_API_KEY,
        token: "MATIC",
    },
    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
        },
    },
}

Please can someone help me. Thank you

1 Answer 1

0

I've found the solution, The error pops up because in the 01-deploy-fundme.js file, you are accessing networkConfig from helper file which tried to read the network setting for it 11155111 but the networkConfig variable is undefined in the deploy file.

The reason is, in you helper file you are not exporting the variables correctly;

module.export = {
    networkConfig,
    developmentChains,
}

it should be module.exports not module.export;

module.exports = {
    networkConfig,
    developmentChains,
}

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.