0

I'm writing a dice betting game which uses Chainlink VRF V2 to get random numbers for the dices. I'm trying to deploy the VRF V2 Mock and then create a subscription and add My currently deployed contract to the list of subscribers.

~/deploy/00-deploy-mocks.js :

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 (developmentChains.includes(network.name)) {
        // only deploying mocks if we are on a development chain
        console.log("Local network detected! Deploying Mocks ...");
        const VRFCoordinatorV2Mock = await deploy("VRFCoordinatorV2Mock", {
            contract:
                "contracts/test/VRFCoordinatorV2Mock.sol:VRFCoordinatorV2Mock",
            from: deployer,
            args: [10000, 10000],
            log: true,
        });
        console.log("Mocks Deployed!");
        console.log(
            "----------------------------------------------------------------------------",
        );
        const subID = await VRFCoordinatorV2Mock.createSubscription();
        console.log(`Subscription Created with SUB ID ${subID}!`);
    }
};

module.exports.tags = ["all", "mocks"];

However the problem is when I deploy using this script, I get the following error:

TypeError: VRFCoordinatorV2Mock.createSubscription is not a function
    at Object.module.exports [as func] (/home/rjey/solidity-files/dice-betting-game/deploy/00-deploy-mocks.js:27:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at listOnTimeout (node:internal/timers:528:9)
    at processTimers (node:internal/timers:502:7)
    at DeploymentsManager.executeDeployScripts (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1211:22)
    at DeploymentsManager.runDeploy (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1060:5)
    at SimpleTaskDefinition.action (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat-deploy/src/index.ts:450:5)
    at Environment._runTaskDefinition (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14)
    at Environment.run (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14)
    at DeploymentsManager.executeDeployScripts (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1214:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at listOnTimeout (node:internal/timers:528:9)
    at processTimers (node:internal/timers:502:7)
    at DeploymentsManager.runDeploy (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1060:5)
    at SimpleTaskDefinition.action (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat-deploy/src/index.ts:450:5)
    at Environment._runTaskDefinition (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat/src/internal/core/runtime-environment.ts:358:14)
    at Environment.run (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat/src/internal/core/runtime-environment.ts:191:14)
    at SimpleTaskDefinition.action (/home/rjey/solidity-files/dice-betting-game/node_modules/hardhat-deploy/src/index.ts:601:32)
error Command failed with exit code 1.

I would like to not use the ethers deploy technique so that's why I'm asking this question. And if there is any better practice for doing what I'm trying to do I would like to hear it from the experts. Would provide anymore details if necessary. Thanks in advance.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.