pragmasolidity^0.8.0;// Note: the ERC-165 identifier for this interface is 0x897e2c73.
interfaceIERC6150/* is IERC721, IERC165 */{/**
* @notice Emitted when `tokenId` token under `parentId` is minted.
* @param minter The address of minter
* @param to The address received token
* @param parentId The id of parent token, if it's zero, it means minted `tokenId` is a root token.
* @param tokenId The id of minted token, required to be greater than zero
*/eventMinted(addressindexedminter,addressindexedto,uint256parentId,uint256tokenId);/**
* @notice Get the parent token of `tokenId` token.
* @param tokenId The child token
* @return parentId The Parent token found
*/functionparentOf(uint256tokenId)externalviewreturns(uint256parentId);/**
* @notice Get the children tokens of `tokenId` token.
* @param tokenId The parent token
* @return childrenIds The array of children tokens
*/functionchildrenOf(uint256tokenId)externalviewreturns(uint256[]memorychildrenIds);/**
* @notice Check the `tokenId` token if it is a root token.
* @param tokenId The token want to be checked
* @return Return `true` if it is a root token; if not, return `false`
*/functionisRoot(uint256tokenId)externalviewreturns(bool);/**
* @notice Check the `tokenId` token if it is a leaf token.
* @param tokenId The token want to be checked
* @return Return `true` if it is a leaf token; if not, return `false`
*/functionisLeaf(uint256tokenId)externalviewreturns(bool);}
可选扩展:可枚举
// Note: the ERC-165 identifier for this interface is 0xba541a2e.
interfaceIERC6150EnumerableisIERC6150/* IERC721Enumerable */{/**
* @notice Get total amount of children tokens under `parentId` token.
* @dev If `parentId` is zero, it means get total amount of root tokens.
* @return The total amount of children tokens under `parentId` token.
*/functionchildrenCountOf(uint256parentId)externalviewreturns(uint256);/**
* @notice Get the token at the specified index of all children tokens under `parentId` token.
* @dev If `parentId` is zero, it means get root token.
* @return The token ID at `index` of all chlidren tokens under `parentId` token.
*/functionchildOfParentByIndex(uint256parentId,uint256index)externalviewreturns(uint256);/**
* @notice Get the index position of specified token in the children enumeration under specified parent token.
* @dev Throws if the `tokenId` is not found in the children enumeration.
* If `parentId` is zero, means get root token index.
* @param parentId The parent token
* @param tokenId The specified token to be found
* @return The index position of `tokenId` found in the children enumeration
*/functionindexInChildrenEnumeration(uint256parentId,uint256tokenId)externalviewreturns(uint256);}
可选扩展:可销毁
// Note: the ERC-165 identifier for this interface is 0x4ac0aa46.
interfaceIERC6150BurnableisIERC6150{/**
* @notice Burn the `tokenId` token.
* @dev Throws if `tokenId` is not a leaf token.
* Throws if `tokenId` is not a valid NFT.
* Throws if `owner` is not the owner of `tokenId` token.
* Throws unless `msg.sender` is the current owner, an authorized operator, or the approved address for this token.
* @param tokenId The token to be burnt
*/functionsafeBurn(uint256tokenId)external;/**
* @notice Batch burn tokens.
* @dev Throws if one of `tokenIds` is not a leaf token.
* Throws if one of `tokenIds` is not a valid NFT.
* Throws if `owner` is not the owner of all `tokenIds` tokens.
* Throws unless `msg.sender` is the current owner, an authorized operator, or the approved address for all `tokenIds`.
* @param tokenIds The tokens to be burnt
*/functionsafeBatchBurn(uint256[]memorytokenIds)external;}
可选扩展:父级可转移
// Note: the ERC-165 identifier for this interface is 0xfa574808.
interfaceIERC6150ParentTransferableisIERC6150{/**
* @notice Emitted when the parent of `tokenId` token changed.
* @param tokenId The token changed
* @param oldParentId Previous parent token
* @param newParentId New parent token
*/eventParentTransferred(uint256tokenId,uint256oldParentId,uint256newParentId);/**
* @notice Transfer parentship of `tokenId` token to a new parent token
* @param newParentId New parent token id
* @param tokenId The token to be changed
*/functiontransferParent(uint256newParentId,uint256tokenId)external;/**
* @notice Batch transfer parentship of `tokenIds` to a new parent token
* @param newParentId New parent token id
* @param tokenIds Array of token ids to be changed
*/functionbatchTransferParent(uint256newParentId,uint256[]memorytokenIds)external;}
可选扩展:访问控制
// Note: the ERC-165 identifier for this interface is 0x1d04f0b3.
interfaceIERC6150AccessControlisIERC6150{/**
* @notice Check the account whether a admin of `tokenId` token.
* @dev Each token can be set more than one admin. Admin have permission to do something to the token, like mint child token,
* or burn token, or transfer parentship.
* @param tokenId The specified token
* @param account The account to be checked
* @return If the account has admin permission, return true; otherwise, return false.
*/functionisAdminOf(uint256tokenId,addressaccount)externalviewreturns(bool);/**
* @notice Check whether the specified parent token and account can mint children tokens
* @dev If the `parentId` is zero, check whether account can mint root nodes
* @param parentId The specified parent token to be checked
* @param account The specified account to be checked
* @return If the token and account has mint permission, return true; otherwise, return false.
*/functioncanMintChildren(uint256parentId,addressaccount)externalviewreturns(bool);/**
* @notice Check whether the specified token can be burnt by specified account
* @param tokenId The specified token to be checked
* @param account The specified account to be checked
* @return If the tokenId can be burnt by account, return true; otherwise, return false.
*/functioncanBurnTokenByAccount(uint256tokenId,addressaccount)externalviewreturns(bool);}