[英]How can I choose my own smart contract addresses on RSK before deploying it?
[英]How can I tell if a smart contract on RSK is an NFT?
給定部署到 RSK 的智能合約的地址,我如何判斷它是否是 NFT? 有沒有“標准”的方式來做到這一點?
是的,如果智能合約為 NFT 實施眾所周知的代幣標准,那么有一個明確的方法可以做到這一點,這反過來又實施了眾所周知的EIP165 標准接口定義。
(1) 最簡單的方法是在 RSK 區塊瀏覽器上查找地址。
If the smart contract address is 0x814eb350813c993df32044f862b800f91e0aaaf0
, then go to https://explorer.rsk.co/address/0x814eb350813c993df32044f862b800f91e0aaaf0
在此頁面上,您將看到一行“合約接口”,在此智能合約的情況下,顯示ERC165 ERC721 ERC721Enumerable ERC721Metadata
。 由於這包含ERC721
,我們知道它為不可替代的代幣實現了該代幣標准。
(2) 更程序化/ DIY的方式是使用EIP165標准中定義的function,其接口復制如下:
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)
supportsInterface(0xd9b67a26)
(請注意,雖然上述兩個值都在各自的標准中進行了說明,但您也可能希望自己計算它們,並且 EIP-165 標准包含有關如何執行此操作的部分。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.