简体   繁体   English

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

[英]How to check if NFT is in a specific wallet

I need to check if a specific NFT is in a specific wallet, there is an API or a way to do it programmatically?我需要检查特定 NFT 是否在特定钱包中,是否有 API 或以编程方式执行此操作的方法?

Thanks a lot.非常感谢。

Assuming the NFT is published onchain and its collection contract implements the ERC-721 standard, you can call the ownerOf() function (defined in the standard) on the collection contract.假设 NFT 是在链上发布的,并且它的收集合约实现了ERC-721标准,你可以在收集合约上调用ownerOf() function(在标准中定义)。

Example using web3js :使用web3js 的示例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM