如何检查NFT是否在特定钱包中

Edo*_*ese 5 blockchain ethereum wallet cryptocurrency nft

我需要检查特定的 NFT 是否在特定的钱包中,是否有 API 或以编程方式执行此操作的方法?

多谢。

Pet*_*jda 3

假设NFT在链上发布,并且其收款合约实现了ERC-721标准,则可以ownerOf()在收款合约上调用该函数(标准中定义)。

使用web3js 的示例:

const collection = new web3.eth.Contract(abiJson, collectionAddress);
const owner = await collection.methods.ownerOf(tokenId).call();
return owner == desiredAddress;
Run Code Online (Sandbox Code Playgroud)

对于ERC-1155标准,您可以使用该balanceOf()函数。

const balance = await collection.methods.balanceOf(owner, ,tokenId).call();
return balance > 0;
Run Code Online (Sandbox Code Playgroud)