Skip to content

Lesson:14 call revert exception; VM Exception while processing transaction #5035

Discussion options

You must be logged in to vote

@Shawon-Mandal This is the issue due to the invalid token Id because while minting you are updating the token id first and then minting an NFT due to that your first NFT index starts at 1 but in the mint file you are accessing at index 0.

function mintNft(int256 highValue) public {
    s_tokenIdToHighValue[s_tokenCounter] = highValue;
    _safeMint(msg.sender, s_tokenCounter);
    s_tokenCounter = s_tokenCounter + 1;
    emit CreateNFT(s_tokenCounter, highValue);
}

You should update it after _safeMint.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Shawon-Mandal
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants