I am trying to release an NFT where it's a free mint for holding another NFT. I am trying to use balanceOf, but I realize this is exploitable without tracking used tokens - as a user could mint 10 NFTs, then transfer the original to another address and mint 10 more.

Inside my freeMint function, here's the part I've added to check the balance. This isn't working every time, so I may not be able to compare balanceOf and mintAmount like I'm doing.

            IToken(otherNFT).balanceOf(_msgSender()) >= _mintAmount,
            "Invalid quantity"

I would appreciate any help you could offer! I have tried to find some example of this but so far haven't had luck.

  • You could require the user to supply a tokenId and check that it is owned by user and then blacklist the tokenId so it cannot be used more than once.
    – Ismael
    Jun 22 at 1:33
  • Yeah, but I might have users that have multiple tokens and I'd like them to be able to mint them all in 1 transaction. I guess I could do a loop through all their tokens but not sure how efficient that is. Jun 22 at 2:07


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.