Lesson 9, Deploying to Rinkeby: TypeError: Cannot read properties of undefined (reading 'undefined') #520
Answered
by
MichaelGKing
MichaelGKing
asked this question in
Q&A
-
Hello, I am receiving the following error when I attempt to deploy to the Rinkeby test network:
I am unsure what to look for with reading being 'undefined'. Any ideas? It is saying it is getting this error when processing my 01-deploy-raffle.js. Here is the code for that file: const { network, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")
const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("30")
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
let vrfCoordinatorV2Address, subscriptionId
if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait(1)
subscriptionId = transactionReceipt.events[0].args.subId
// Need to fund subscription.
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, VRF_SUB_FUND_AMOUNT)
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"]
subscriptionId = networkConfig["chainId"][subscriptionId]
}
const entranceFee = networkConfig[chainId]["entranceFee"]
const gasLane = networkConfig[chainId]["gasLane"]
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"]
const interval = networkConfig[chainId]["interval"]
const args = [
vrfCoordinatorV2Address,
entranceFee,
gasLane,
subscriptionId,
callbackGasLimit,
interval,
]
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) {
log("Verifying")
await verify(raffle.address, args)
}
log("-----------------------------------------------------------------")
}
module.exports.tags = ["all", "raffle"] Any help would be much appreciated, thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
MichaelGKing
Jun 23, 2022
Replies: 1 comment
-
Issue turned out to be incorrect syntax: subscriptionId = networkConfig["chainId"][subscriptionId] Should be: subscriptionId = networkConfig[chainId]["subscriptionId"] |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MichaelGKing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue turned out to be incorrect syntax:
Should be: