Comment on page
RMRKNestable
RMRK team
RMRKNestable
Smart contract of the RMRK Nestable module.
This contract is hierarchy agnostic and can support an arbitrary number of nested levels up and down, as long as gas limits allow it.
function VERSION() external view returns (string)
Version of the @rmrk-team/evm-contracts package
Name | Type | Description |
---|---|---|
_0 | string | undefined |
function acceptChild(uint256 parentId, uint256 childIndex, address childAddress, uint256 childId) external nonpayable
Used to accept a pending child token for a given parent token.
This moves the child token from parent token's pending child tokens array into the active child tokens array.
Name | Type | Description |
---|---|---|
parentId | uint256 | ID of the parent token for which the child token is being accepted |
childIndex | uint256 | Index of a child tokem in the given parent's pending children array |
childAddress | address | Address of the collection smart contract of the child token expected to be located at the specified index of the given parent token's pending children array |
childId | uint256 | ID of the child token expected to be located at the specified index of the given parent token's pending children array |
function addChild(uint256 parentId, uint256 childId, bytes data) external nonpayable
Used to add a child token to a given parent token.
This adds the child token into the given parent token's pending child tokens array.Requirements: -
directOwnerOf
on the child contract must resolve to the called contract. - the pending array of the parent contract must not be full.Name | Type | Description |
---|---|---|
parentId | uint256 | ID of the parent token to receive the new child token |
childId | uint256 | ID of the new proposed child token |
data | bytes | Additional data with no specified format |
function approve(address to, uint256 tokenId) external nonpayable
Used to grant a one-time approval to manage one's token.
Gives permission to
to
to transfer tokenId
token to another account.The approval is cleared when the token is transferred.Only a single account can be approved at a time, so approving the zero address clears previous approvals.Requirements: - The caller must own the token or be an approved operator. - tokenId
must exist.Emits an {Approval} event.Name | Type | Description |
---|---|---|
to | address | Address receiving the approval |
tokenId | uint256 | ID of the token for which the approval is being granted |
function balanceOf(address owner) external view returns (uint256)
Used to retrieve the number of tokens in
owner
's account.Name | Type | Description |
---|---|---|
owner | address | Address of the account being checked |
Name | Type | Description |
---|---|---|
_0 | uint256 | The balance of the given account |
function burn(uint256 tokenId) external nonpayable
Used to burn a given token.
In case the token has any child tokens, the execution will be reverted.
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token to burn |
function burn(uint256 tokenId, uint256 maxChildrenBurns) external nonpayable returns (uint256)
Used to burn a given token.
When a token is burned, all of its child tokens are recursively burned as well.When specifying the maximum recursive burns, the execution will be reverted if there are more children to be burned.Setting the
maxRecursiveBurn
value to 0 will only attempt to burn the specified token and revert if there are any child tokens present.The approvals are cleared when the token is burned.Requirements: - tokenId
must exist.Emits a {Transfer} event.Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token to burn |
maxChildrenBurns | uint256 | undefined |
Name | Type | Description |
---|---|---|
_0 | uint256 | Number of recursively burned children |
function childOf(uint256 parentId, uint256 index) external view returns (struct IERC6059.Child)
Used to retrieve a specific active child token for a given parent token.
Returns a single Child struct locating at
index
of parent token's active child tokens array.The Child struct consists of the following values: [ tokenId, contractAddress ]Name | Type | Description |
---|---|---|
parentId | uint256 | ID of the parent token for which the child is being retrieved |
index | uint256 | Index of the child token in the parent token's active child tokens array |
Name | Type | Description |
---|---|---|
_0 | IERC6059.Child | A Child struct containing data about the specified child |
function childrenOf(uint256 parentId) external view returns (struct IERC6059.Child[])
Used to retrieve the active child tokens of a given parent token.
Returns array of Child structs existing for parent token.The Child struct consists of the following values: [ tokenId, contractAddress ]
Name | Type | Description |
---|---|---|
parentId | uint256 | ID of the parent token for which to retrieve the active child tokens |
Name | Type | Description |
---|---|---|
_0 | IERC6059.Child[] | An array of Child structs containing the parent token's active child tokens |
function directOwnerOf(uint256 tokenId) external view returns (address, uint256, bool)
Used to retrieve the immediate owner of the given token.
If the immediate owner is another token, the address returned, should be the one of the parent token's collection smart contract.
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token for which the RMRK owner is being retrieved |
Name | Type | Description |
---|---|---|
_0 | address | Address of the given token's owner |
_1 | uint256 | The ID of the parent token. Should be 0 if the owner is an externally owned account |
_2 | bool | The boolean value signifying whether the owner is an NFT or not |
function getApproved(uint256 tokenId) external view returns (address)
Used to retrieve the account approved to manage given token.
Requirements: -
tokenId
must exist.Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token to check for approval |
Name | Type | Description |
---|---|---|
_0 | address | Address of the account approved to manage the token |
function isApprovedForAll(address owner, address operator) external view returns (bool)
Used to check if the given address is allowed to manage the tokens of the specified address.
Name | Type | Description |
---|---|---|
owner | address | Address of the owner of the tokens |
operator | address | Address being checked for approval |
Name | Type | Description |
---|---|---|
_0 | bool | A boolean value signifying whether the operator is allowed to manage the tokens of the owner ( true ) or not (false ) |
function name() external view returns (string)
Used to retrieve the collection name.
Name | Type | Description |
---|---|---|
_0 | string | Name of the collection |
function nestTransferFrom(address from, address to, uint256 tokenId, uint256 destinationId, bytes data) external nonpayable
Used to transfer the token into another token.
Name | Type | Description |
---|---|---|
from | address | Address of the direct owner of the token to be transferred |
to | address | Address of the receiving token's collection smart contract |
tokenId | uint256 | ID of the token being transferred |
destinationId | uint256 | ID of the token to receive the token being transferred |
data | bytes | Additional data with no specified format, sent in the addChild call |
function ownerOf(uint256 tokenId) external view returns (address)
Used to retrieve the root owner of a given token.
The root owner of the token is an externally owned account (EOA). If the given token is child of another NFT, this will return an EOA address. Otherwise, if the token is owned by an EOA, this EOA wil be returned.
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token for which the root owner has been retrieved |
Name | Type | Description |
---|---|---|
_0 | address | The root owner of the token |
function pendingChildOf(uint256 parentId, uint256 index) external view returns (struct IERC6059.Child)
Used to retrieve a specific pending child token from a given parent token.
Returns a single Child struct locating at
index
of parent token's active child tokens array.The Child struct consists of the following values: [ tokenId, contractAddress ]Name | Type | Description |
---|---|---|
parentId | uint256 | ID of the parent token for which the pending child token is being retrieved |
index | uint256 | Index of the child token in the parent token's pending child tokens array |
Name | Type | Description |
---|---|---|
_0 | IERC6059.Child | A Child struct containting data about the specified child |
function pendingChildrenOf(uint256 parentId) external view returns (struct IERC6059.Child[])
Used to retrieve the pending child tokens of a given parent token.
Returns array of pending Child structs existing for given parent.The Child struct consists of the following values: [ tokenId, contractAddress ]
Name | Type | Description |
---|---|---|
parentId | uint256 | ID of the parent token for which to retrieve the pending child tokens |
Name | Type | Description |
---|---|---|
_0 | IERC6059.Child[] | An array of Child structs containing the parent token's pending child tokens |
function rejectAllChildren(uint256 tokenId, uint256 maxRejections) external nonpayable
Used to reject all pending children of a given parent token.
Removes the children from the pending array mapping.This does not update the ownership storage data on children. If necessary, ownership can be reclaimed by the rootOwner of the previous parent.Requirements: Requirements: -
parentId
must existName | Type | Description |
---|---|---|
tokenId | uint256 | undefined |
maxRejections | uint256 | Maximum number of expected children to reject, used to prevent from rejecting children which arrive just before this operation. |
function safeTransferFrom(address from, address to, uint256 tokenId) external nonpayable
Used to safely transfer a given token token from
from
to to
.Requirements: -
from
cannot be the zero address. - to
cannot be the zero address. - tokenId
token must exist and be owned by from
. - If the caller is not from
, it must be approved to move this token by either {approve} or {setApprovalForAll}. - If to
refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.Emits a {Transfer} event.Name | Type | Description |
---|---|---|
from | address | Address to transfer the tokens from |
to | address | Address to transfer the tokens to |
tokenId | uint256 | ID of the token to transfer |
function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) external nonpayable
Used to safely transfer a given token token from
from
to to
.Requirements: -
from
cannot be the zero address. - to
cannot be the zero address. - tokenId
token must exist and be owned by from
. - If the caller is not from
, it must be approved to move this token by either {approve} or {setApprovalForAll}. - If to
refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.Emits a {Transfer} event.Name | Type | Description |
---|---|---|
from | address | Address to transfer the tokens from |
to | address | Address to transfer the tokens to |
tokenId | uint256 | ID of the token to transfer |
data | bytes | Additional data without a specified format to be sent along with the token transaction |
function setApprovalForAll(address operator, bool approved) external nonpayable
Used to approve or remove
operator
as an operator for the caller.Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.Requirements: - The
operator
cannot be the caller.Emits an {ApprovalForAll} event.Name | Type | Description |
---|---|---|
operator | address | Address of the operator being managed |
approved | bool | A boolean value signifying whether the approval is being granted ( true ) or (revoked ) |
function supportsInterface(bytes4 interfaceId) external view returns (bool)
Returns true if this contract implements the interface defined by
interfaceId
. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.Name | Type | Description |
---|---|---|
interfaceId | bytes4 | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function symbol() external view returns (string)
Used to retrieve the collection symbol.
Name | Type | Description |
---|---|---|
_0 | string | Symbol of the collection |
function transferChild(uint256 tokenId, address to, uint256 destinationId, uint256 childIndex, address childAddress, uint256 childId, bool isPending, bytes data) external nonpayable
Used to transfer a child token from a given parent token.
When transferring a child token, the owner of the token is set to
to
, or is not updated in the event of to
being the 0x0
address.Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the parent token from which the child token is being transferred |
to | address | Address to which to transfer the token to |
destinationId | uint256 | ID of the token to receive this child token (MUST be 0 if the destination is not a token) |
childIndex | uint256 | Index of a token we are transferring, in the array it belongs to (can be either active array or pending array) |
childAddress | address | Address of the child token's collection smart contract. |
childId | uint256 | ID of the child token in its own collection smart contract. |
isPending | bool | A boolean value indicating whether the child token being transferred is in the pending array of the parent token ( true ) or in the active array (false ) |
data | bytes | Additional data with no specified format, sent in call to _to |
function transferFrom(address from, address to, uint256 tokenId) external nonpayable
Transfers a given token from
from
to to
.Requirements: -
from
cannot be the zero address. - to
cannot be the zero address. - tokenId
token must be owned by from
. - If the caller is not from
, it must be approved to move this token by either {approve} or {setApprovalForAll}.Emits a {Transfer} event.Name | Type | Description |
---|---|---|
from | address | Address from which to transfer the token from |
to | address | Address to which to transfer the token to |
tokenId | uint256 | ID of the token to transfer |
event AllChildrenRejected(uint256 indexed tokenId)
Used to notify listeners that all pending child tokens of a given token have been rejected.
Emitted when a token removes all a child tokens from its pending array.
Name | Type | Description |
---|---|---|
tokenId indexed | uint256 | ID of the token that rejected all of the pending children |
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)
Emitted when
owner
enables approved
to manage the tokenId
token.Name | Type | Description |
---|---|---|
owner indexed | address | undefined |
approved indexed | address | undefined |
tokenId indexed | uint256 | undefined |
event ApprovalForAll(address indexed owner, address indexed operator, bool approved)
Emitted when
owner
enables or disables (approved
) operator
to manage all of its assets.Name | Type | Description |
---|---|---|
owner indexed | address | undefined |
operator indexed | address | undefined |
approved | bool | undefined |
event ChildAccepted(uint256 indexed tokenId, uint256 childIndex, address indexed childAddress, uint256 indexed childId)
Used to notify listeners that a new child token was accepted by the parent token.
Emitted when a parent token accepts a token from its pending array, migrating it to the active array.
Name | Type | Description |
---|---|---|
tokenId indexed | uint256 | ID of the token that accepted a new child token |
childIndex | uint256 | Index of the newly accepted child token in the parent token's active children array |
childAddress indexed | address | Address of the child token's collection smart contract |
childId indexed | uint256 | ID of the child token in the child token's collection smart contract |
event ChildProposed(uint256 indexed tokenId, uint256 childIndex, address indexed childAddress, uint256 indexed childId)
Used to notify listeners that a new token has been added to a given token's pending children array.
Emitted when a child NFT is added to a token's pending array.
Name | Type | Description |
---|---|---|
tokenId indexed | uint256 | ID of the token that received a new pending child token |