Cyfrin / foundry-smart-contract-lottery-cu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

createSubscription function should support both Mock and Real VRFCoordinator contracts

meitedaf opened this issue · comments

Issue Description:

The function is located in foundry-smart-contract-lottery-cu/script/Interactions.s.sol.

This implementation uses the VRFCoordinatorV2Mock type to call the createSubscription function, which means that regardless of whether the passed vrfCoordinator address is a mock or the actual VRFCoordinator contract, it will always use the mock contract's createSubscription function.

function createSubscription(
    address vrfCoordinator
) public returns (uint64) {
    console.log("Create subscription on ChainID: ", block.chainid);
    vm.startBroadcast();
    uint64 subId = VRFCoordinatorV2Mock(vrfCoordinator).createSubscription();
    vm.stopBroadcast();
    console.log("Your subId is: ", subId);
    console.log("Please update your subscriptionID in HelperConfig");
    return subId;
}

I watched the later video where you manually entered the subscriptionId 😂, but before that I was confused, I thought I could create a real subscriptionId using the createSubscription function

It's nice you pointed this out @meitedaf, it might be confusing for other users as well. Can you point us to the specific video on Updraft so we can add and update?