const { network, ethers } = require("hardhat")
const { developmentChain } = require("../helper-hardhat-config")
const { networkConfig } = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")
const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("50")
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
let vrfCoordinatorV2Address, subscriptionId
if (/*developmentChain.includes(network.name)*/ chainId == 31337) {
const vrfCoordinatorV2Mock = await deployments.get("VRFCoordinatorV2Mock")
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address
//creation of subscription id and funding it for local testing
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait(1)
subscriptionId = transactionReceipt.events[0].args.subId
//fund the subscription
//on real testnet we need LINK
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.blockConfirmation || 1,
})
if (
/*!developmentChain.includes(network.name)*/ !chainId == 31337 &&
process.env.ETHERSCAN_API_KEY
) {
log("Veryfying on etherscan...")
await verify(raffle.address, args)
}
log("--------------------------------------------------")
}
module.exports.tags = ["all", "raffle"]
An unexpected error occurred:
yarn hardhat deploy
yarn run v1.22.19
warning package.json: No license field
$ '/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/.bin/hardhat' deploy
Nothing to compile
Local network detected! Deploying Mocks....
deploying "VRFCoordinatorV2Mock" (tx: 0x7a943804391704783ffc0b6311b856826b2463755365e0d92fd92bd9a39afe3b)...: deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3 with 2971793 gas
Mocks Deployed!
--------------------------------------------------
An unexpected error occurred:
Error: ERROR processing /home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/deploy/01-deploy-raffle.js:
TypeError: vrfCoordinatorV2Mock.createSubscription is not a function
at Object.module.exports [as func] (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/deploy/01-deploy-raffle.js:17:64)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
at DeploymentsManager.executeDeployScripts (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1211:22)
at DeploymentsManager.runDeploy (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1060:5)
at SimpleTaskDefinition.action (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat-deploy/src/index.ts:450:5)
at Environment._runTaskDefinition (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14)
at Environment.run (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14)
at DeploymentsManager.executeDeployScripts (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1214:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
at DeploymentsManager.runDeploy (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1060:5)
at SimpleTaskDefinition.action (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat-deploy/src/index.ts:450:5)
at Environment._runTaskDefinition (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14)
at Environment.run (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14)
at SimpleTaskDefinition.action (/home/rajvir_singh/FCC Full stack Web3 course/Hardhat Lottery L9/node_modules/hardhat-deploy/src/index.ts:601:32)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Can someone help me out with this.. I am having no idea what mistake I am making.