Skip to content

Lesson 14: reverted with custom error 'InvalidConsumer()' #1375

Answered by ghost
IbrahimGhasia asked this question in Q&A
Discussion options

You must be logged in to vote

You should add this line in your deploy script (02-deploy-random-ipfs-nft.js) after you deploy both vrfCoordinatorV2Mock and randomIpfsNft:

await vrfCoordinatorV2Mock.addConsumer(
        subscriptionId,
        randomIpfsNft.address
    )

In code it will loke like this:

Its because you created subscription but you didn't add a consumers for this subscription, so VRF revert you with this message. VRF add this modifier to function requestRandomWords :

function consumerIsAdded(uint64 _subId, address _consumer) public view returns (bool) {
    address[] memory consumers = s_consumers[_subId];
    for (uint256 i = 0; i < consumers.length; i++) {
      if (consumers[i] == _consumer) {
        r…

Replies: 4 comments 25 replies

Comment options

You must be logged in to vote
5 replies
@IbrahimGhasia
Comment options

@alymurtazamemon
Comment options

@IbrahimGhasia
Comment options

@Starmand6
Comment options

@IbrahimGhasia
Comment options

Comment options

You must be logged in to vote
9 replies
@haraslub
Comment options

@luloxi
Comment options

@web3-wizzard
Comment options

@mohammedalasly
Comment options

@786Ayush
Comment options

Comment options

You must be logged in to vote
9 replies
@achimstruve
Comment options

@alexboisseau
Comment options

@ezescigo
Comment options

@nenadV91
Comment options

@TaylorDurden
Comment options

Answer selected by alymurtazamemon
Comment options

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

@seunAwonugba
Comment options

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