Comment on page
RMRKMinifiedEquippable
RMRK team
RMRKMinifiedEquippable
Smart contract of the RMRK Equippable module, without utility internal functions.
This includes all the code for MultiAsset, Nestable and Equippable.Most of the code is duplicated from the other legos, this version is created to save size.
function RMRK_INTERFACE() external view returns (bytes4)
Name | Type | Description |
---|---|---|
_0 | bytes4 | undefined |
function VERSION() external view returns (string)
Version of the @rmrk-team/evm-contracts package
Name | Type | Description |
---|---|---|
_0 | string | undefined |
function acceptAsset(uint256 tokenId, uint256 index, uint64 assetId) external nonpayable
Accepts a 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.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 that is being accepted |
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 approveForAssets(address to, uint256 tokenId) external nonpayable
Used to grant approvals for specific tokens to a specified address.
This can only be called by the owner of the token or by an account that has been granted permission to manage all of the owner's assets.
Name | Type | Description |
---|---|---|
to | address | Address of the account to receive the approval to the specified token |
tokenId | uint256 | ID of the token for which we are granting the permission |
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 canTokenBeEquippedWithAssetIntoSlot(address parent, uint256 tokenId, uint64 assetId, uint64 slotId) external view returns (bool)
Used to verify whether a token can be equipped into a given parent's slot.
Name | Type | Description |
---|---|---|
parent | address | Address of the parent token's smart contract |
tokenId | uint256 | ID of the token we want to equip |
assetId | uint64 | ID of the asset associated with the token we want to equip |
slotId | uint64 | ID of the slot that we want to equip the token into |
Name | Type | Description |
---|---|---|
_0 | bool | A boolean indicating whether the token with the given asset can be equipped into the desired slot |
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 equip(IERC6220.IntakeEquip data) external nonpayable
Name | Type | Description |
---|---|---|
data | IERC6220.IntakeEquip | undefined |
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.
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token for which to retrieve the priorities of the active assets |
Name | Type | Description |
---|---|---|
_0 | uint64[] | An array of priorities of the active assets of the given token |
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 10kName | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token to retrieve the IDs of the active assets |
Name | Type | Description |
---|---|---|
_0 | uint64[] | An array of active asset IDs of the given token |
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 getApprovedForAssets(uint256 tokenId) external view returns (address)
Used to get the address of the user that is approved to manage the specified token from the current owner.
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token we are checking |
Name | Type | Description |
---|---|---|
_0 | address | Address of the account that is approved to manage the token |
function getAssetAndEquippableData(uint256 tokenId, uint64 assetId) external view returns (string, uint64, address, uint64[])
Used to get the asset and equippable data associated with given
assetId
.Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token for which to retrieve the asset |
assetId | uint64 | ID of the asset of which we are retrieving |
Name | Type | Description |
---|---|---|
_0 | string | The metadata URI of the asset |
_1 | uint64 | ID of the equippable group this asset belongs to |
_2 | address | The address of the catalog the part belongs to |
_3 | uint64[] | An array of IDs of parts included in the asset |
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.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 |
Name | Type | Description |
---|---|---|
_0 | string | The metadata of the asset belonging to the specified index in the token's active assets array |
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)
.Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token to check |
newAssetId | uint64 | ID of the pending asset which will be accepted |
Name | Type | Description |
---|---|---|
_0 | uint64 | ID of the asset which will be replaced |
function getEquipment(uint256 tokenId, address targetCatalogAddress, uint64 slotPartId) external view returns (struct IERC6220.Equipment)
Used to get the Equipment object equipped into the specified slot of the desired token.
The
Equipment
struct consists of the following data: [ assetId, childAssetId, childId, childEquippableAddress ]Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token for which we are retrieving the equipped object |
targetCatalogAddress | address | Address of the Catalog associated with the Slot part of the token |
slotPartId | uint64 | ID of the Slot part that we are checking for equipped objects |
Name | Type | Description |
---|---|---|
_0 | IERC6220.Equipment | The Equipment struct containing data about the equipped object |
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)
.Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token to retrieve the IDs of the pending assets |
Name | Type | Description |
---|---|---|
_0 | uint64[] | An array of pending asset IDs of the given 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 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}.
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 |
Name | Type | Description |
---|---|---|
_0 | bool | A boolean value indicating wehter the account we are checking has been granted the operator role |
function isChildEquipped(uint256 tokenId, address childAddress, uint256 childId) external view returns (bool)
Used to check whether the token has a given child equipped.
This is used to prevent from transferring a child that is equipped.
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the parent token for which we are querying for |
childAddress | address | Address of the child token's smart contract |
childId | uint256 | ID of the child token |
Name | Type | Description |
---|---|---|
_0 | bool | A boolean value indicating whether the child token is equipped into the given token or not |
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 ext