Lesson 9: TypeError: Cannot read property 'length' of undefined #777
-
I tried to deploy my solidity code but it is not going successfully. I have tried to follow a similar problem posted here but the error still persists. This is the error:
This is my const { network, ethers } = require("hardhat");
const { developmentChains } = require("../helper-hardhat-config");
const BASE_FEE = ethers.utils.parseEther("0.25");
const GAS_PRICE_LINK = 1e9;
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments;
const { deployer } = getNamedAccounts();
const args = [BASE_FEE, GAS_PRICE_LINK];
if (developmentChains.includes(network.name)) {
log("Local network detected! Deploying mocks...");
await deploy("VRFCoordinatorV2Mock", {
from: deployer,
log: true,
args: args,
});
log("Mocks Deployed!");
log("------------------------------------------------");
}
};
module.exports.tags = ["all", "mocks"]; This is require("dotenv").config();
require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-waffle");
require("hardhat-gas-reporter");
require("solidity-coverage");
require("hardhat-deploy");
require("hardhat-contract-sizer");
const RINKEBY_RPC_URL = process.env.RINKEBY_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: "0.8.7",
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 31337,
blockConfirmations: 1,
},
rinkeby: {
url: RINKEBY_RPC_URL,
chainId: 4,
accounts: [PRIVATE_KEY],
blockConfirmations: 6,
},
},
namedAccounts: {
deployer: {
default: 0,
1: 0,
},
player: {
default: 1,
},
},
}; This is const { ethers } = require("hardhat");
const networkConfig = {
4: {
name: "rinkeby",
vrfCoordinatorV2: "0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
subscriptionId: "0",
callbackGasLimit: "500000",
interval: "30",
},
31337: {
name: "localhost",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
callbackGasLimit: "500000",
interval: "30",
},
};
const developmentChains = ["hardhat", "localhost"];
module.exports = {
networkConfig,
developmentChains,
}; @PatrickAlphaC @ali-thegilfoyle What is the way out? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
This has been asked a number of times, please be sure to look back at previously asked questions! You'll see you need to do: const { deployer } = await getNamedAccounts(); |
Beta Was this translation helpful? Give feedback.
This has been asked a number of times, please be sure to look back at previously asked questions!
#69
You'll see you need to do: