给定部署到RSK的智能合约的地址,我如何判断它是否是NFT?有没有一种“标准”的方法来做到这一点?
发布于 2021-06-11 23:15:05
是的,如果智能合约为NFT实现众所周知的令牌标准,进而实现众所周知的EIP165 Standard Interface Definition,那么就有一种明确的方法来实现这一点。
(1)最简单的方法是简单地在RSK块浏览器上查找地址。
如果智能合约地址为0x814eb350813c993df32044f862b800f91e0aaaf0,则转到https://explorer.rsk.co/address/0x814eb350813c993df32044f862b800f91e0aaaf0
在此页面上,您将看到"Contract Interfaces“行,并且在此智能合约的情况下,显示ERC165 ERC721 ERC721Enumerable ERC721Metadata。因为它包含ERC721,所以我们知道它为不可替换令牌实现了令牌标准。
(2)更具编程性/ DIY的方法是使用EIP165标准中定义的函数,其接口复制如下:
interface ERC165 {
/// @notice Query if a contract implements an interface
/// @param interfaceID The interface identifier, as specified in ERC-165
/// @dev Interface identification is specified in ERC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}如果调用supportsInterface返回true,那么您就知道这个智能合约(声称)实现了那个特定的接口。
如果要测试特定智能合约是否实现了supportsInterface(0x80ac58cd),请调用
(请注意,虽然上述两个值在各自的标准中都有说明,但您可能还希望自己计算它们,并且EIP-165标准包含了有关如何计算它们的部分。)
https://stackoverflow.com/questions/67939427
复制相似问题