13

怎么获取ERC1155一个address的全部token id | 登链社区 | 技术问答

 3 years ago
source link: https://learnblockchain.cn/question/2251
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
怎么获取ERC1155一个address的全部token id

10 怎么获取ERC1155一个address的全部token id

回答问题即可获得 5 经验值,回答被采纳后即可获得 20 学分。

在钱包上支持ERC1155,只有账户地址的情况下没办法获取该地址所持有的token id,

获取token余额必须要知道account和tokneid,所以先要知道该账号有的tokenid

function balanceOf(address account, uint256 id) public view override returns (uint256) {
        require(account != address(0), "ERC1155: balance query for the zero address");
        return _balances[id][account];
    }

存储结构为mapping,没有数组,无法通过遍历获取

// Mapping from token ID to account balances
    mapping (uint256 => mapping(address => uint256)) private _balances;

有什么办法可以显示一个账号下的所有ERC1155 token


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK