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.
require(
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.