How to check if an address owns an NFT (ERC721)?

So I have an ERC721 Contract when I mint NFTs then let users clone them but then they get added to the list of tokens, now I need to know if the current user/address owns this NFT? thanks

1 Like

Hi @x5engine,

I assume you are doing this off chain.

First you can check if the address hold any of the token by checking the addresses balance using balanceOf

You can then loop through the tokens held by the address to get the tokenID using tokenOfOwnerByIndex

1 Like

yes that’s a nice way and i know that but what if the user owns a lot of cloned NFTs? I will have to loop over all of them to find it? for only this tokenid?

1 Like

Hi @x5engine,

I am not sure what you mean by cloned NFTs?

Can you describe your use case a bit more if possible?