Core
Modular
Equippable
IERC6220

IERC6220

RMRK team

IERC6220

Interface smart contract of the RMRK equippable module.

Methods

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

NameTypeDescription
tokenIduint256ID of the token for which to accept the pending asset
indexuint256Index of the asset in the pending array to accept
assetIduint64ID of the asset expected to be in the index

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

NameTypeDescription
toaddressAddress of the account to grant the approval to
tokenIduint256ID of the token for which the approval to manage the assets is granted

canTokenBeEquippedWithAssetIntoSlot

function canTokenBeEquippedWithAssetIntoSlot(address parent, uint256 tokenId, uint64 assetId, uint64 slotId) external view returns (bool canBeEquipped)

Used to verify whether a token can be equipped into a given parent's slot.

Parameters

NameTypeDescription
parentaddressAddress of the parent token's smart contract
tokenIduint256ID of the token we want to equip
assetIduint64ID of the asset associated with the token we want to equip
slotIduint64ID of the slot that we want to equip the token into

Returns

NameTypeDescription
canBeEquippedboolA boolean indicating whether the token with the given asset can be equipped into the desired slot

equip

function equip(IERC6220.IntakeEquip data) external nonpayable

Parameters

NameTypeDescription
dataIERC6220.IntakeEquipundefined

getActiveAssetPriorities

function getActiveAssetPriorities(uint256 tokenId) external view returns (uint64[] priorities)

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

NameTypeDescription
tokenIduint256ID of the token for which to retrieve the priorities of the active assets

Returns

NameTypeDescription
prioritiesuint64[]An array of priorities of the active assets of the given token

getActiveAssets

function getActiveAssets(uint256 tokenId) external view returns (uint64[] assetIds)

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

NameTypeDescription
tokenIduint256ID of the token to retrieve the IDs of the active assets

Returns

NameTypeDescription
assetIdsuint64[]An array of active asset IDs of the given token

getApprovedForAssets

function getApprovedForAssets(uint256 tokenId) external view returns (address approved)

Used to retrieve the address of the account approved to manage assets of a given token.

Requirements: - tokenId must exist.

Parameters

NameTypeDescription
tokenIduint256ID of the token for which to retrieve the approved address

Returns

NameTypeDescription
approvedaddressAddress of the account that is approved to manage the specified token's assets

getAssetAndEquippableData

function getAssetAndEquippableData(uint256 tokenId, uint64 assetId) external view returns (string metadataURI, uint64 equippableGroupId, address catalogAddress, uint64[] partIds)

Used to get the asset and equippable data associated with given assetId.

Parameters

NameTypeDescription
tokenIduint256ID of the token for which to retrieve the asset
assetIduint64ID of the asset of which we are retrieving

Returns

NameTypeDescription
metadataURIstringThe metadata URI of the asset
equippableGroupIduint64ID of the equippable group this asset belongs to
catalogAddressaddressThe address of the catalog the part belongs to
partIdsuint64[]An array of IDs of parts included in the asset

getAssetMetadata

function getAssetMetadata(uint256 tokenId, uint64 assetId) external view returns (string metadata)

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

NameTypeDescription
tokenIduint256ID of the token from which to retrieve the asset metadata
assetIduint64Asset Id, must be in the active assets array

Returns

NameTypeDescription
metadatastringThe 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 replacesAssetWithId)

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

NameTypeDescription
tokenIduint256ID of the token to check
newAssetIduint64ID of the pending asset which will be accepted

Returns

NameTypeDescription
replacesAssetWithIduint64ID of the asset which will be replaced

getEquipment

function getEquipment(uint256 tokenId, address targetCatalogAddress, uint64 slotPartId) external view returns (struct IERC6220.Equipment 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 ]

Parameters

NameTypeDescription
tokenIduint256ID of the token for which we are retrieving the equipped object
targetCatalogAddressaddressAddress of the Catalog associated with the Slot part of the token
slotPartIduint64ID of the Slot part that we are checking for equipped objects

Returns

NameTypeDescription
equipmentIERC6220.EquipmentThe Equipment struct containing data about the equipped object

getPendingAssets

function getPendingAssets(uint256 tokenId) external view returns (uint64[] assetIds)

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

NameTypeDescription
tokenIduint256ID of the token to retrieve the IDs of the pending assets

Returns

NameTypeDescription
assetIdsuint64[]An array of pending asset IDs of the given token

isApprovedForAllForAssets

function isApprovedForAllForAssets(address owner, address operator) external view returns (bool isApproved)

Used to check whether the address has been granted the operator role by a given address or not.

See {setApprovalForAllForAssets}.

Parameters

NameTypeDescription
owneraddressAddress of the account that we are checking for whether it has granted the operator role
operatoraddressAddress of the account that we are checking whether it has the operator role or not

Returns

NameTypeDescription
isApprovedboolA boolean value indicating whether the account we are checking has been granted the operator role

isChildEquipped

function isChildEquipped(uint256 tokenId, address childAddress, uint256 childId) external view returns (bool isEquipped)

Used to check whether the token has a given child equipped.

This is used to prevent from transferring a child that is equipped.

Parameters

NameTypeDescription
tokenIduint256ID of the parent token for which we are querying for
childAddressaddressAddress of the child token's smart contract
childIduint256ID of the child token

Returns

NameTypeDescription
isEquippedboolA boolean value indicating whether the child token is equipped into the given token or not

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

NameTypeDescription
tokenIduint256ID of the token of which to clear the pending array.
maxRejectionsuint256Maximum number of expected assets to reject, used to prevent from rejecting assets 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

NameTypeDescription
tokenIduint256ID of the token that the asset is being rejected from
indexuint256Index of the asset in the pending array to be rejected
assetIduint64ID of the asset expected to be in the index

setApprovalForAllForAssets

function setApprovalForAllForAssets(address operator, bool approved) external nonpayable

Used to add or remove an operator of assets for the caller.

Operators can call {acceptAsset}, {rejectAsset}, {rejectAllAssets} or {setPriority} for any token owned by the caller.Requirements: - The operator cannot be the caller.Emits an {ApprovalForAllForAssets} event.

Parameters

NameTypeDescription
operatoraddressAddress of the account to which the operator role is granted or revoked from
approvedboolThe boolean value indicating whether the operator role is being granted (true) or revoked (false)

setPriority

function setPriority(uint256 tokenId, uint64[] priorities) external nonpayable

Sets a new priority array for a given token.

The priority array is a non-sequential list of uint64s, where the lowest value is considered highest priority.Value 0 of a priority is a special case equivalent to unitialized.Requirements: - The caller must own the token or be approved to manage the token's assets - tokenId must exist. - The length of priorities must be equal the length of the active assets array.Emits a {AssetPrioritySet} event.

Parameters

NameTypeDescription
tokenIduint256ID of the token to set the priorities for
prioritiesuint64[]An array of priorities of active assets. The succesion of items in the priorities array matches that of the succesion of items in the active array

supportsInterface

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 (opens in a new tab) section] to learn more about how these ids are created. This function call must use less than 30 000 gas.

Parameters

NameTypeDescription
interfaceIdbytes4undefined

Returns

NameTypeDescription
_0boolundefined

unequip

function unequip(uint256 tokenId, uint64 assetId, uint64 slotPartId) external nonpayable

Used to unequip child from parent token.

This can only be called by the owner of the token or by an account that has been granted permission to manage the given token by the current owner.

Parameters

NameTypeDescription
tokenIduint256ID of the parent from which the child is being unequipped
assetIduint64ID of the parent's asset that contains the Slot into which the child is equipped
slotPartIduint64ID of the Slot from which to unequip the child

Events

ApprovalForAllForAssets

event ApprovalForAllForAssets(address indexed owner, address indexed operator, bool approved)

Used to notify listeners that owner has granted approval to the user to manage assets of all of their tokens.

Parameters

NameTypeDescription
owner indexedaddressAddress of the account that has granted the approval for all assets on all of their tokens
operator indexedaddressAddress of the account that has been granted the approval to manage the token's assets on all of the tokens
approvedboolBoolean value signifying whether the permission has been granted (true) or revoked (false)

ApprovalForAssets

event ApprovalForAssets(address indexed owner, address indexed approved, uint256 indexed tokenId)

Used to notify listeners that owner has granted an approval to the user to manage the assets of a given token.

Approvals must be cleared on transfer

Parameters

NameTypeDescription
owner indexedaddressAddress of the account that has granted the approval for all token's assets
approved indexedaddressAddress of the account that has been granted approval to manage the token's assets
tokenId indexeduint256ID of the token on which the approval was granted

AssetAccepted

event AssetAccepted(uint256 indexed tokenId, uint64 indexed assetId, uint64 indexed replacesId)

Used to notify listeners that an asset object at assetId is accepted by the token and migrated from token's pending assets array to active assets array of the token.

Parameters

NameTypeDescription
tokenId indexeduint256ID of the token that had a new asset accepted
assetId indexeduint64ID of the asset that was accepted
replacesId indexeduint64ID of the asset that was replaced

AssetAddedToTokens

event AssetAddedToTokens(uint256[] tokenIds, uint64 indexed assetId, uint64 indexed replacesId)

Used to notify listeners that an asset object at assetId is added to token's pending asset array.

Parameters

NameTypeDescription
tokenIdsuint256[]An array of token IDs that received a new pending asset
assetId indexeduint64ID of the asset that has been added to the token's pending assets array
replacesId indexeduint64ID of the asset that would be replaced

AssetPrioritySet

event AssetPrioritySet(uint256 indexed tokenId)

Used to notify listeners that token's prioritiy array is reordered.

Parameters

NameTypeDescription
tokenId indexeduint256ID of the token that had the asset priority array updated

AssetRejected

event AssetRejected(uint256 indexed tokenId, uint64 indexed assetId)

Used to notify listeners that an asset object at assetId is rejected from token and is dropped from the pending assets array of the token.

Parameters

NameTypeDescription
tokenId indexeduint256ID of the token that had an asset rejected
assetId indexeduint64ID of the asset that was rejected

AssetSet

event AssetSet(uint64 indexed assetId)

Used to notify listeners that an asset object is initialized at assetId.

Parameters

NameTypeDescription
assetId indexeduint64ID of the asset that was initialized

ChildAssetEquipped

event ChildAssetEquipped(uint256 indexed tokenId, uint64 indexed assetId, uint64 indexed slotPartId, uint256 childId, address childAddress, uint64 childAssetId)

Used to notify listeners that a child's asset has been equipped into one of its parent assets.

Parameters

NameTypeDescription
tokenId indexeduint256ID of the token that had an asset equipped
assetId indexeduint64ID of the asset associated with the token we are equipping into
slotPartId indexeduint64ID of the slot we are using to equip
childIduint256ID of the child token we are equipping into the slot
childAddressaddressAddress of the child token's collection
childAssetIduint64ID of the asset associated with the token we are equipping

ChildAssetUnequipped

event ChildAssetUnequipped(uint256 indexed tokenId, uint64 indexed assetId, uint64 indexed slotPartId, uint256 childId, address childAddress, uint64 childAssetId)

Used to notify listeners that a child's asset has been unequipped from one of its parent assets.

Parameters

NameTypeDescription
tokenId indexeduint256ID of the token that had an asset unequipped
assetId indexeduint64ID of the asset associated with the token we are unequipping out of
slotPartId indexeduint64ID of the slot we are unequipping from
childIduint256ID of the token being unequipped
childAddressaddressAddress of the collection that a token that is being unequipped belongs to
childAssetIduint64ID of the asset associated with the token we are unequipping

ValidParentEquippableGroupIdSet

event ValidParentEquippableGroupIdSet(uint64 indexed equippableGroupId, uint64 indexed slotPartId, address parentAddress)

Used to notify listeners that the assets belonging to a equippableGroupId have been marked as equippable into a given slot and parent

Parameters

NameTypeDescription
equippableGroupId indexeduint64ID of the equippable group being marked as equippable into the slot associated with slotPartId of the parentAddress collection
slotPartId indexeduint64ID of the slot part of the catalog into which the parts belonging to the equippable group associated with equippableGroupId can be equipped
parentAddressaddressAddress of the collection into which the parts belonging to equippableGroupId can be equipped