检查合同上给定的NFT ID是否已铸造

发布于 2025-02-12 11:46:18 字数 135 浏览 0 评论 0原文

NFT合同是在ERC-721上使用的,

我们需要最简单的方法来检查NFT Collection的令牌ID是否到目前为止是铸造的。无论是否被铸造并转移了几次。

只是铸造,真

或仍然没有铸造,错误,

谢谢

NFT contract is on ERC-721

we need the most simple way to check if Token ID from NFT collection is minted so far or not. no matter if it is minted and transferred several times.

just if minted , true

or still not minted, false

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

护你周全 2025-02-19 11:46:18

erc-721 标准标准定义了holderof()函数,将令牌ID作为输入参数。

它要么返回NFT持有人的地址,要么如果不存在令牌ID(即分配给地址零)。

const collection = new web3.eth.Contract(ABI, ADDRESS);
try {
    await collection.methods.ownerOf(tokenId).call();
    // exists
} catch (e) {
    // does not exist
}

The ERC-721 standard defines the ownerOf() function, accepting the token ID as an input param.

It either returns address of the NFT holder, or throws if the token ID does not exist (i.e. is assigned to address zero).

const collection = new web3.eth.Contract(ABI, ADDRESS);
try {
    await collection.methods.ownerOf(tokenId).call();
    // exists
} catch (e) {
    // does not exist
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文