Lesson 9: TypeError: vrfCoordinatorV2Mock.createSubscription is not a function #1293
-
My Mocks are getting deployedsuccessfully but I am getting errors while deploying the contract. My 01-deploy.js: const { network, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../helper-hardhat-config");
const { verify } = require("../helper-hardhat-config");
const FUND_AMOUNT = ethers.utils.parseEther("2");
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.getContractFactory("VRFCoordinatorV2Mock")
vrfCoordinatorV2address = vrfCoordinatorV2Mock.address;
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait(1)
subscriptionId = transactionReceipt.events[0].args.subId
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, FUND_AMOUNT)
} else {
vrfCoordinatorV2address = networkConfig[chainId]["vrfCoordinatorV2"];
subscriptionId = networkConfig[chainId]["subscriptionId"];
}
const entranceFee = networkConfig[chainId]["entranceFee"];
const keyHash = networkConfig[chainId]["keyHash"];
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"];
const interval = networkConfig[chainId]["interval"];
const bingo = await deploy("Bingo", {
from: deployer,
args: [vrfCoordinatorV2address, entranceFee, keyHash, subscriptionId, callbackGasLimit, interval],
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) {
log("Verifying...")
await verify(bingo.address, args)
}
}
module.exports.tags = ["all", "bingo"] Err:
Help pls. Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
Muhammad-Abdullah012
Jul 25, 2022
Replies: 1 comment 1 reply
-
Instead of const vrfCoordinatorV2Mock = await ethers.getContractFactory("VRFCoordinatorV2Mock"); Try this, const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock") |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
TradMod
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of
Try this,