AlphaWallet / AlphaWallet/alpha-wallet-ios

Support ERC721Enumerable

Open
#4,361 0 comments 0 reactions 1 assignee Claimed by @hboon View on GitHub
Dominant language
Swift
Stars
631
Forks
384
PR merge metrics
No merged PRs in 30d

Description

ERC721Enumerable is a "new" standard for ERC721. It has a fetch balance system similar to how ERC875 used to work.

The new function you will be using is: ```uint256 tokenOfOwnerByIndex({wallet address}, index)```

- When you check the EIP165 interface you can check for ```INTERFACE_ERC721ENUMERABLE```. This is defined as ```bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;```. The ERC721Enumerable will also identify as the standard ERC721 interface.
- Once you have an ERC721 of this kind you can fetch full TokenId balance array quite easily:

1. Obtain numerical count of NFTs as normal ERC721 using ```uint256 balanceOf({wallet address})``` which returns how many ERC721 tokens the wallet has.
2. Iterate through the count to find all the tokenIds eg
```for (i = 0; i < count; i++)```
```tokenId = tokenOfOwnerByIndex({wallet address}, i)```

eg

```balanceOf()``` of NFT returns 3 tokens; ```tokenOfOwnerByIndex()``` for 0,1,2 ->

0 -> 2556
1 -> 3456
2 -> 4431

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.