Lesson 7 log("Mocks deployed!") TypeError: Cannot read properties of undefined (reading 'indexOf') #2462
-
Hello I am having this error message come up when I run yarn hardhat deploy --tags "mocks
const { network, deployments } = require("hardhat")
const {
developmentChains,
DECIMALS,
INITIAL_ANSWER,
} = require("../helper-hardhat-config")
module.exports = async ({ getNameAccounts, deloyments }) => {
const { deploy, log } = deployments
const { deployer } = await getNameAccounts()
if (chainId == 31337) {
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"] Here is my helper-hardhat-config.js const networkConfig = {
4: {
name: "rinkeby",
ethUsdPriceFeed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e",
},
137: {
name: "polygon",
ethUsdPriceFeed: "OxF9680D99D6C9589e2a93a78A04A279e5092059454",
},
31337: {
name: "localhost",
},
}
const developmentChains = ["hardhat", "localhost"]
const DECIMALS = 8
const INITIAL_ANSWER = 200000000000
module.exports = {
networkConfig,
developmentChains,
DECIMALS,
INITIAL_ANSWER,
} Here is my 01-deploy-fund-me.js // 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 } = require("../helper-hardhat-config")
const { network } = require("hardhat")
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"]
// 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
const fundMe = await deploy("FundMe", {
from: deployer,
args: [
/* Address */
], // put price feed address
log: true,
})
} Please let me know what you think I can do to fix it... thank you so much in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@JuniorSua : Correct the following mistakes, I'm listing below in your mocks deploy script :
Corrections should be like this :
Just Copy & Paste all of the changes! And run this command after that : |
Beta Was this translation helpful? Give feedback.
@JuniorSua : Correct the following mistakes, I'm listing below in your mocks deploy script :
module.exports.tags = ["all", , "mocks"]
Corrections should be like this :
Also define chainId in your module.exports