Skip to content

Lesson 14: Unit-testing 'emit Minted()' not working, also txReceipt-issue #2287

Answered by RoboCrypter
ManuWeb3 asked this question in Q&A
Discussion options

You must be logged in to vote

@ManuWeb3 : There are couple of things I wanna correct :

  1. In your mintNft function in your BasicNft contract, You were updating the token counter after minting the NFT, which is incorrect.
    Always update your token counter before minting the NFT is the best practice and preferable way, and also will not create any problems for you later on!

    It should be like this :

    function mintNft() public {
        s_tokenCounter++;
        _safeMint(msg.sender, s_tokenCounter);
        emit Minted(msg.sender, s_tokenCounter);
        //  return s_tokenCounter;                      //  not serving any purpose, can be removed
    }

And, yes return s_tokenCounter; is not needed.

  1. In your basicNft.t…

Replies: 2 comments 10 replies

Comment options

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

Comment options

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

@RoboCrypter
Comment options

@ManuWeb3
Comment options

@ManuWeb3
Comment options

@RoboCrypter
Comment options

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