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?

A post was split to a new topic: tokenOfOwnerByIndex is undefined

Hello, I wonder if can check if an address has an ERC721 token from another contract ERC721?
sorry if open a thread but I can’t find anything on the internet

similar to address.balance = amount of ether

address.erc721 exists?

hello. i'm looking to solve a similar issue. did you get any solutions please?.