Skip to content

Lesson: 9 Error: VM Exception while processing transaction: reverted with custom error 'InvalidConsumer()' #6521

Closed Answered by Nlferu
HrithikKeshri10 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @hrithikk28

You just need to add consumer in your deploy script first.

    // Ensure the Raffle contract is a valid consumer of the VRFCoordinatorV2Mock contract.
    if (developmentChains.includes(network.name)) {
        log(`Adding Consumer...`)
        const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
        await vrfCoordinatorV2Mock.addConsumer(subscriptionId, raffle.address)
        log(`Consumer Successfully Added!`)
    }
    // Checking If Deployed Raffle Is Added To Consumer List...
    // Adding Raffle Contract To Consumer List If It Is Not...
    else {
        const getConsumers = await vrfCoordinatorV2.getSubscription(subscriptionId)
        

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@HrithikKeshri10
Comment options

@Nlferu
Comment options

Answer selected by HrithikKeshri10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants