Links
Comment on page

RMRKNestableMultiAsset

RMRK team
RMRKNestableMultiAsset
Smart contract of the joined RMRK Nestable and Multi asset module.

Methods

VERSION

function VERSION() external view returns (string)
Version of the @rmrk-team/evm-contracts package

Returns

Name
Type
Description
_0
string
undefined

acceptAsset

function acceptAsset(uint256 tokenId, uint256 index, uint64 assetId) external nonpayable
Accepts an asset at from the pending array of given token.
Migrates the asset from the token's pending asset array to the token's active asset array.Active assets cannot be removed by anyone, but can be replaced by a new asset.Requirements: - The caller must own the token or be approved to manage the token's assets - tokenId must exist. - index must be in range of the length of the pending asset array.Emits an {AssetAccepted} event.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token for which to accept the pending asset
index
uint256
Index of the asset in the pending array to accept
assetId
uint64
ID of the asset expected to be in the index

acceptChild

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.

Parameters

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

addChild

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.

Parameters

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

approve

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.

Parameters

Name
Type
Description
to
address
Address receiving the approval
tokenId
uint256
ID of the token for which the approval is being granted

approveForAssets

function approveForAssets(address to, uint256 tokenId) external nonpayable
Used to grant permission to the user to manage token's assets.
This differs from transfer approvals, as approvals are not cleared when the approved party accepts or rejects an asset, or sets asset priorities. This approval is cleared on token transfer.Only a single account can be approved at a time, so approving the 0x0 address clears previous approvals.Requirements: - The caller must own the token or be an approved operator. - tokenId must exist.Emits an {ApprovalForAssets} event.

Parameters

Name
Type
Description
to
address
Address of the account to grant the approval to
tokenId
uint256
ID of the token for which the approval to manage the assets is granted

balanceOf

function balanceOf(address owner) external view returns (uint256)
Used to retrieve the number of tokens in owner's account.

Parameters

Name
Type
Description
owner
address
Address of the account being checked

Returns

Name
Type
Description
_0
uint256
The balance of the given account

burn

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.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token to burn

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.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token to burn
maxChildrenBurns
uint256
undefined

Returns

Name
Type
Description
_0
uint256
Number of recursively burned children

childOf

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 ]

Parameters

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

Returns

Name
Type
Description
_0
IERC6059.Child
A Child struct containing data about the specified child

childrenOf

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 ]

Parameters

Name
Type
Description
parentId
uint256
ID of the parent token for which to retrieve the active child tokens

Returns

Name
Type
Description
_0
IERC6059.Child[]
An array of Child structs containing the parent token's active child tokens

directOwnerOf

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.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token for which the RMRK owner is being retrieved

Returns

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

getActiveAssetPriorities

function getActiveAssetPriorities(uint256 tokenId) external view returns (uint64[])
Used to retrieve the priorities of the active resoources of a given token.
Asset priorities are a non-sequential array of uint64 values with an array size equal to active asset priorites.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token for which to retrieve the priorities of the active assets

Returns

Name
Type
Description
_0
uint64[]
An array of priorities of the active assets of the given token

getActiveAssets

function getActiveAssets(uint256 tokenId) external view returns (uint64[])
Used to retrieve IDs of the active assets of given token.
Asset data is stored by reference, in order to access the data corresponding to the ID, call getAssetMetadata(tokenId, assetId).You can safely get 10k

Parameters

Name
Type
Description
tokenId
uint256
ID of the token to retrieve the IDs of the active assets

Returns

Name
Type
Description
_0
uint64[]
An array of active asset IDs of the given token

getApproved

function getApproved(uint256 tokenId) external view returns (address)
Used to retrieve the account approved to manage given token.
Requirements: - tokenId must exist.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token to check for approval

Returns

Name
Type
Description
_0
address
Address of the account approved to manage the token

getApprovedForAssets

function getApprovedForAssets(uint256 tokenId) external view returns (address)
Used to retrieve the address of the account approved to manage assets of a given token.
Requirements: - tokenId must exist.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token for which to retrieve the approved address

Returns

Name
Type
Description
_0
address
Address of the account that is approved to manage the specified token's assets

getAssetMetadata

function getAssetMetadata(uint256 tokenId, uint64 assetId) external view returns (string)
Used to fetch the asset metadata of the specified token's active asset with the given index.
Assets are stored by reference mapping _assets[assetId].Can be overriden to implement enumerate, fallback or other custom logic.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token from which to retrieve the asset metadata
assetId
uint64
Asset Id, must be in the active assets array

Returns

Name
Type
Description
_0
string
The metadata of the asset belonging to the specified index in the token's active assets array

getAssetReplacements

function getAssetReplacements(uint256 tokenId, uint64 newAssetId) external view returns (uint64)
Used to retrieve the asset that will be replaced if a given asset from the token's pending array is accepted.
Asset data is stored by reference, in order to access the data corresponding to the ID, call getAssetMetadata(tokenId, assetId).

Parameters

Name
Type
Description
tokenId
uint256
ID of the token to check
newAssetId
uint64
ID of the pending asset which will be accepted

Returns

Name
Type
Description
_0
uint64
ID of the asset which will be replaced

getPendingAssets

function getPendingAssets(uint256 tokenId) external view returns (uint64[])
Used to retrieve IDs of the pending assets of given token.
Asset data is stored by reference, in order to access the data corresponding to the ID, call getAssetMetadata(tokenId, assetId).

Parameters

Name
Type
Description
tokenId
uint256
ID of the token to retrieve the IDs of the pending assets

Returns

Name
Type
Description
_0
uint64[]
An array of pending asset IDs of the given token

isApprovedForAll

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.

Parameters

Name
Type
Description
owner
address
Address of the owner of the tokens
operator
address
Address being checked for approval

Returns

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)

isApprovedForAllForAssets

function isApprovedForAllForAssets(address owner, address operator) external view returns (bool)
Used to check whether the address has been granted the operator role by a given address or not.
See {setApprovalForAllForAssets}.

Parameters

Name
Type
Description
owner
address
Address of the account that we are checking for whether it has granted the operator role
operator
address
Address of the account that we are checking whether it has the operator role or not

Returns

Name
Type
Description
_0
bool
A boolean value indicating wehter the account we are checking has been granted the operator role

name

function name() external view returns (string)
Used to retrieve the collection name.

Returns

Name
Type
Description
_0
string
Name of the collection

nestTransferFrom

function nestTransferFrom(address from, address to, uint256 tokenId, uint256 destinationId, bytes data) external nonpayable
Used to transfer the token into another token.

Parameters

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

ownerOf

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.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token for which the root owner has been retrieved

Returns

Name
Type
Description
_0
address
The root owner of the token

pendingChildOf

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 ]

Parameters

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

Returns

Name
Type
Description
_0
IERC6059.Child
A Child struct containting data about the specified child

pendingChildrenOf

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 ]

Parameters

Name
Type
Description
parentId
uint256
ID of the parent token for which to retrieve the pending child tokens

Returns

Name
Type
Description
_0
IERC6059.Child[]
An array of Child structs containing the parent token's pending child tokens

rejectAllAssets

function rejectAllAssets(uint256 tokenId, uint256 maxRejections) external nonpayable
Rejects all assets from the pending array of a given token.
Effecitvely deletes the pending array.Requirements: - The caller must own the token or be approved to manage the token's assets - tokenId must exist.Emits a {AssetRejected} event with assetId = 0.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token of which to clear the pending array.
maxRejections
uint256
Maximum number of expected assets to reject, used to prevent from rejecting assets which arrive just before this operation.

rejectAllChildren

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 exist

Parameters

Name
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.

rejectAsset

function rejectAsset(uint256 tokenId, uint256 index, uint64 assetId) external nonpayable
Rejects an asset from the pending array of given token.
Removes the asset from the token's pending asset array.Requirements: - The caller must own the token or be approved to manage the token's assets - tokenId must exist. - index must be in range of the length of the pending asset array.Emits a {AssetRejected} event.

Parameters

Name
Type
Description
tokenId
uint256
ID of the token that the asset is being rejected from
index
uint256
Index of the asset in the pending array to be rejected
assetId
uint64
ID of the asset expected to be in the index

safeTransferFrom

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.

Parameters