Core
Other
Utils
Collection Utils

RMRKCollectionUtils

RMRK team

RMRKCollectionUtils

Smart contract of the RMRK Collection utils module.

Extra utility functions for RMRK contracts.

Methods

getCollectionData

function getCollectionData(address collection) external view returns (struct RMRKCollectionUtils.CollectionData data)

Used to get the collection data of a specified collection.

The full CollectionData struct looks like this: [ totalSupply, maxSupply, royaltyPercentage, royaltyRecipient, owner, symbol, name, collectionMetadata ]

Parameters

NameTypeDescription
collectionaddressAddress of the collection to get the data from

Returns

NameTypeDescription
dataRMRKCollectionUtils.CollectionDataCollection data struct containing the collection data

getInterfaceSupport

function getInterfaceSupport(address collection) external view returns (bool supports721, bool supportsMultiAsset, bool supportsNesting, bool supportsEquippable, bool supportsSoulbound, bool supportsRoyalties)

Used to get the interface support of a specified collection.

Parameters

NameTypeDescription
collectionaddressAddress of the collection to get the interface support from

Returns

NameTypeDescription
supports721boolBoolean value signifying whether the collection supports ERC721 interface
supportsMultiAssetboolBoolean value signifying whether the collection supports MultiAsset interface (ERC5773)
supportsNestingboolBoolean value signifying whether the collection supports Nestable interface (ERC7401)
supportsEquippableboolBoolean value signifying whether the collection supports Equippable interface (ERC6220)
supportsSoulboundboolBoolean value signifying whether the collection supports Soulbound interface (ERC6454)
supportsRoyaltiesboolBoolean value signifying whether the collection supports Royaltiesy interface (ERC2981)

getPaginatedMintedIds

function getPaginatedMintedIds(address targetEquippable, uint256 pageStart, uint256 pageSize) external view returns (uint256[] page)

Used to get a list of existing token IDs in the range between pageStart and pageSize.

It is not optimized to avoid checking IDs out of max supply nor total supply, since this is not meant to be used during transaction execution; it is only meant to be used as a getter.The resulting array might be smaller than the given pageSize since no-existent IDs are not included.

Parameters

NameTypeDescription
targetEquippableaddressAddress of the collection smart contract of the given token
pageStartuint256The first ID to check
pageSizeuint256The number of IDs to check

Returns

NameTypeDescription
pageuint256[]An array of IDs of the existing tokens

refreshCollectionTokensMetadata

function refreshCollectionTokensMetadata(address collectionAddress, uint256 fromTokenId, uint256 toTokenId) external nonpayable

Triggers an event to refresh the collection metadata.

It will do nothing if the given collection address is not a contract.

Parameters

NameTypeDescription
collectionAddressaddressAddress of the collection to refresh the metadata from
fromTokenIduint256ID of the first token to refresh the metadata from
toTokenIduint256ID of the last token to refresh the metadata from

refreshTokenMetadata

function refreshTokenMetadata(address collectionAddress, uint256 tokenId) external nonpayable

Triggers an event to refresh the token metadata.

It will do nothing if the given collection address is not a contract.

Parameters

NameTypeDescription
collectionAddressaddressAddress of the collection to refresh the metadata from
tokenIduint256ID of the token to refresh the metadata from

Events

BatchMetadataUpdate

event BatchMetadataUpdate(address indexed collection, uint256 indexed fromTokenId, uint256 indexed toTokenId)

This event emits when the metadata of a range of tokens is changed. So that the third-party platforms such as NFT market could timely update the images and related attributes of the NFTs. Inspired on ERC4906, but adding collection.

Parameters

NameTypeDescription
collection indexedaddressAddress of the collection to emit the event from
fromTokenId indexeduint256ID of the first token to emit the event from
toTokenId indexeduint256ID of the last token to emit the event from

MetadataUpdate

event MetadataUpdate(address indexed collection, uint256 indexed tokenId)

This event emits when the metadata of a token is changed. So that the third-party platforms such as NFT market could timely update the images and related attributes of the NFT. Inspired on ERC4906, but adding collection.

Parameters

NameTypeDescription
collection indexedaddressAddress of the collection to emit the event from
tokenId indexeduint256ID of the token to emit the event from