I have a simple ERC721 smart contract used for testing purposes, I was wondering if it is possible to query the token IDs a specific wallet owns in that smart contract.
eventually I would like to display the NFTs minted by the user in the website.
balanceOf in the contract returns the number of tokens owned by the user, but no further info.
my test smart contract:
Looks like your contract inherits an extension of ERC721 called ERC721Enumerable.
This extension adds a function called tokenOfOwnerByIndex(address owner, uint256 index)
, which can used to list all tokens owned by a user (owner
). So you can call this function multiple times, looping index
from 0
to balanceOf(owner)
to get all tokens ids.