Comment on page
RMRKEquippableLazyMintErc20
RMRK team
RMRKEquippableLazyMintErc20
Implementation of RMRK equippable module with ERC20-powered lazy minting.
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 addAssetEntry(string metadataURI) external nonpayable returns (uint256)
Used to add a asset entry.
The ID of the asset is automatically assigned to be the next available asset ID.
Name | Type | Description |
---|---|---|
metadataURI | string | Metadata URI of the asset |
Name | Type | Description |
---|---|---|
_0 | uint256 | ID of the newly added asset |
function addAssetToToken(uint256 tokenId, uint64 assetId, uint64 replacesAssetWithId) external nonpayable
Used to add an asset to a token.
If the given asset is already added to the token, the execution will be reverted.If the asset ID is invalid, the execution will be reverted.If the token already has the maximum amount of pending assets (128), the execution will be reverted.
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the token to add the asset to |
assetId | uint64 | ID of the asset to add to the token |
replacesAssetWithId | uint64 | ID of the asset to replace from the token's list of active assets |
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 addEquippableAssetEntry(uint64 equippableGroupId, address catalogAddress, string metadataURI, uint64[] partIds) external nonpayable returns (uint256)
Used to add an equippable asset entry.
The ID of the asset is automatically assigned to be the next available asset ID.
Name | Type | Description |
---|---|---|
equippableGroupId | uint64 | ID of the equippable group |
catalogAddress | address | Address of the Catalog smart contract this asset belongs to |
metadataURI | string | Metadata URI of the asset |
partIds | uint64[] | An array of IDs of fixed and slot parts to be included in the asset |
Name | Type | Description |
---|---|---|
_0 | uint256 | The total number of assets after this asset has been added |
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 collectionMetadata() external view returns (string)
Used to retrieve the metadata of the collection.
Name | Type | Description |
---|---|---|
_0 | string | string The metadata URI of the collection |
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 erc20TokenAddress() external view returns (address)
Used to retrieve the address of the ERC20 token this smart contract supports.
Name | Type | Description |
---|---|---|
_0 | address | Address of the ERC20 token's smart contract |
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 getRoyaltyPercentage() external view returns (uint256)
Used to retrieve the specified royalty percentage.
Name | Type | Description |
---|---|---|
_0 | uint256 |