如何获取 NEAR 账户中的所有 NFT?

How can I fetch all NFTs within a NEAR account?

假设所有 NFT 都遵守 NEP-171 specification,我如何列出一个帐户内的所有 NFT,例如 example.near

我在 https://docs.rs/near-contract-standards/latest/near_contract_standards/macro.impl_non_fungible_token_enumeration.html 看到它应该是可能的。

使用 NEAR CLI,运行 类似于 NEAR_ENV=testnet near view <the contract ID> nft_tokens_for_owner '{"account_id": "<the account ID>"}'

参见 https://nomicon.io/Standards/NonFungibleToken/Enumeration.html#interface

from_index 默认为 0,limit 默认为无限制。

示例:

NEAR_ENV=testnet near view dev-1643292007908-55838431863482 nft_tokens_for_owner '{"account_id": "example.testnet"}'