Intro:
I am trying to use ERC721Enumerable in my NFT contract so I can get the set of all NFTs owned by a particular address.
Research:
The ERC721Enumerable contract was implemented to enumerate unique NFTs, to make them discoverable. The way to discover them is by iterating through the enumerated NFT ids using the following function:
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);
I presume the best way to get an entire set of an address's assets is to query this function multiple times, while incrementing the _index
variable from 0 -> n, until no such NFT exists - then you will end up with all of the assets of that contract owned by the particular address. But that seems hacky to me.
Question:
I'm wondering if the ERC721Enumerable contract has a better way to tell me the entire list of an address's owned NFTs.
_index == balanceOf(_owner) - 1
.