Hello!
I am working on something similar and I’m trying to get the balance for NFTs that I made. I’m trying to use token by index but it is not working. It returns an error that tokenOfOwnerByIndex is undefined. Is this used with web3 or on its own? Is there a dependency I’m missing? Also does this work on the Ropsten testnet or only main net? Thank you for your help!
1 Like
Hi @ag.lwsn,
Welcome to the community
Which version of OpenZeppelin Contracts are you using?
In OpenZeppelin Contracts 3.4 tokenOfOwnerByIndex
is in ERC721
In OpenZeppelin Contracts 4.0 Beta tokenOfOwnerByIndex
is in ERC721Enumerable
so you can choose whether or not to include enumerability on chain or whether you can do this off chain and save gas instead.
I assume you are using OpenZeppelin Contracts 4.0 Beta. You may want to look at using a service like The Graph to enumerate the tokens.