0

I've got an ERC721 contract as part of a larger react dApp. My app is connected using web3 tools to the user's wallet. I need to be able to see if the address connected has a token balance for my contract (easy-peasy) but more importantly, I'd really like to know what token IDs in particular of my NFT contract the connected address owns.

This is easy for me to accomplish IF I iterate thru the minted NFTs by building a function in the contract & returning info to my UX. But I really don't want to iterate every time a user connects. I'm wondering if the tokenIDs can be gleaned from info that is in the wallet. I don't want to iterate onchain & I've noticed with metamask, for instance, it knows how many NFTs my address is holding once the token is known to the wallet - it displays the balance. So I'm wondering, do wallets also what the NFT tokenIDs are that it owns? Can that info be read by talking to the wallet?

I really appreciate everyone's feedback - thanks! cb

1 Answer 1

1

In ERC721 standart you cannot get the what NFTs an address owns, just number of tokens. You can iterate over all tokens one by one to check their owners, or better use a 3rd party API that provides that information for you.

Covalent offers a free API for querying the token balances of an address. Documentation is here.

2
  • 1
    Thanks - that's what I needed to know! I'll check out Covalent
    – chrisb
    Jun 29 at 21:21
  • please consider marking as answer if helped
    – ofarukcaki
    Jul 4 at 19:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.