TypeError: Cannot read property 'length' of undefined - Lesson 7, 10:48:53 #69
-
I am getting the following error while trying to deploy a Mock contract on the hardhat development chain. I am following:
I got this error while I was at Ques: Where do I think the problem is occurring? (12:26)
Here is the error:
Here is the code snippet in which I am getting the error: const { network } = require("hardhat");
const { developmentChains, DECIMALS, INITIAL_ANSWER } = require("../helper-hardhat-config");
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
if (chainId == 31337) {
console.log("Development network detected! Deploying mocks...");
const feedMock = await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMALS, INITIAL_ANSWER],
});
log("Price Feed Mock deployed!");
log("==============================================");
}
}
module.exports.tags = ["all", "mocks"]; Please help me with this problem 🥹 System configuration: MacBook Air M1 2021 - Monterey 12.4, yarn: 1.22.18, Hardhat: 2.9.6 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Amazing question! When you call You'll want to make sure this is in there! namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
},
}, One addition, please add the name of the language to the 3 backticks when formatting, like so:
|
Beta Was this translation helpful? Give feedback.
Amazing question!
When you call
await getNamedAccounts()
, it looks in yourhardhat.config.js
for thenamedAccounts
section, and reads the length of the named accounts.You'll want to make sure this is in there!
One addition, please add the name of the language to the 3 backticks when formatting, like so: