Skip to content

Lesson14: Getting "URI query for non-existing token " error at 23:28 while deploying DynamicSvg Nft on local network #2779

Answered by alymurtazamemon
ritesh798 asked this question in Q&A
Discussion options

You must be logged in to vote

@ritesh798

In this function;

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

You are increasing counter value before minting an NFT, so what going on behind the scene is that when you first time mint the NFT, it gets mint for tokenId 1 instead of 0, and that is the reason when you are trying to get the NFT with tokenId 0 in the mint script, it is reverting an error.

Fix it and things will work smoothly.

change it to this;

function mintNft(int256 highValue) public {
    s_tokenIdToHighValue[s_tokenCounter] = h…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ritesh798
Comment options

Answer selected by ritesh798
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