Replies: 2 comments 4 replies
-
The token counter + 1 is used to keep track of NFTs minted. For example, I mint an NFT token 001 then you mint the same one. Yours will be token counter + 1 or NFT token 002 that way each of our NFT ownership is clearly defined. I hope this helps answering your question |
Beta Was this translation helpful? Give feedback.
-
@MrAbuz Yup, your curiosity is right. Here is the way we update the token counter; uint256 private s_tokenCounter;
constructor() {
s_tokenCounter = 0;
}
function mintNft(int256 highValue) public {
uint256 tokenId = s_tokenCounter;
s_tokenCounter = s_tokenCounter + 1;
// ...do further things
} Now you use the same tokenId for the minting and for the event as well. In addition to that, you also update the state of a counter before making the external calls. There is the issue in the repo code and due to that people face issues. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello guys! Hope everyone's well, and doing well in the course!
I'm having a super basic question here. In the Lesson 13 -> DynamicSvgNft.sol, we have:
If we do "s_tokenCounter + 1" between minting and emitting, won't the emit send a different s_tokenCounter than the one that was used in the mint? The purpose should be to emit the same tokenCounter (which is the nft tokenId) that was minted.
I got even more confused because in the video (23:14:23) Patrick suggested that "it's a best practise to update the token counter before actually doing the minting". So in the video he did it like this:
But like this, in the first line, the user will update the s_tokenIdToHighValues mapping using a different token counter than the token counter that will be assigned to him in the mint. Which, if someone remembers this NFT project, will make the user assign an ETH price for his NFT to change face to a different token ID than the one that will be assigned to him in the mint, which would make him not being able to choose the ETH price for his NFT.
Should the code be as following (updating token counter before anything else), or what am I missing?
Thank you in advance!! eheh
Beta Was this translation helpful? Give feedback.
All reactions