I have a pretty basic contract that allows people to mint NFT's. I'm able to check the balance of the total amount of NFT's the user owns relative to the initial mint contract:
connectedContract.balanceOf(web3React.account).then((d) => {
console.log(parseInt(d))
})
Is there a way I can show which NFT's the wallet owns that is only relative to the contract address?
Best Answer
Your actual code should only show you the balance of NFT owned by the account on your contract.
Appears to be your contract. So the Balance is related to that contract.
If you did not implement the Enumerable set. To get all the NFT's of an account you would have to loop over them and call
An example;
I strongly recommend that you take a look at the openZeppelin Enumerable contract that provide an easier way of going trough a user NFT balance.
To understand what each OZ extension add to the ERC721 you can visit this link.
OZ Contracts
You want to import the required extensions in your contract.
For what you want to do you can use
It will essentially provide you with exactly what you want! The process is similar. You get the balance, and you can get the index of each token based on the balance.