AlphaWallet / AlphaWallet/alpha-wallet-ios

Support ERC721Enumerable

未關閉
#4,361 0 則留言 0 個 reaction 已指派 1 人 已被 @hboon 認領 在 GitHub 檢視
主要語言
Swift
星號
631
分支
384
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。