Skip to main content

mQuarkTemplate

Manages creation of templates and categories with useful view functions.

Functions​

createTemplate​

 function createTemplate(string calldata uri) external;

Creates a new template with the given URI, which will be inherited by collections.

Parameters:​

NameTypeDescription
uristringThe metadata URI that will represent the template.

createBatchTemplate​

  function createBatchTemplate(string[] calldata uris) external;

Creates multiple templates with the given URIs, which will be inherited by collections.

Parameters:​

NameTypeDescription
urisstring[]The metadata URIs that will represent the templates.

createCategory​

  function createCategory(string calldata name, string calldata uri) external;

This function allows the creation of a new category.

Parameters:​

NameTypeDescription
namestringThe name of the new category.
uristringThe URI associated with the category.

createBatchCategory​

  function createBatchCategory(string[] calldata names, string[] calldata uris) external;

Creates new categories with the given names and URIs.

Parameters:​

NameTypeDescription
namestring[] calldataThe name of the new category.
uristring[] calldataThe metadata URI that will represent the category.

setTemplateCategory​

  function setTemplateCategory(
string calldata category,
uint256[] calldata templateIds_
) external;

Sets the given templates to a category.

Parameters:​

NameTypeDescription
categorystringThe category name for the templates (e.g., "vehicle").
templateIdsstringAn array of template IDs that will be set to the given category (e.g., [1, 2, 3]).

removeCategoryFromTemplate​

  function removeCategoryFromTemplate(string memory category, uint256 templateId) external;

Removes a given template from a given category.

Parameters:​

NameTypeDescription
categorystringThe category name for the template.
templateIduint256The template ID that will be removed from the category.

templateUri​

  function templateUri(uint256 templateId) external view returns (string memory)

Templates defines what a token is. Every template id has its own properties and attributes. Collections are created by templates. Inherits the properties and attributes of the template.

Parameters:​

NameTypeDescription
templateIduint256Template ID

Return Values:​

TypeDescription
stringTemplate's URI
  function getProjectSlotPrice(uint256 projectId) external view returns (uint256)

Returns project's slot's price.

Parameters:​

NameTypeDescription
projectIduint256Project ID

Return Values:​

TypeDescription
uint256Project's Slot Price

getLastTemplateId​

  function getLastTemplateId() external view returns (uint256)

This function returns the total number of templates that have been created so far.

Return Values:​

TypeDescription
uint256The total number of templates that have been created.
  function getProjectSlotPrice(uint256 projectId) external view returns (uint256)

Returns project's slot's price.

Parameters:​

NameTypeDescription
projectIduint256Project ID

Return Values:​

TypeDescription
uint256Project's Slot Price

isTemplateIdExist​

  function isTemplateIdExist(uint256 templateId) external view returns (bool exist)

Checks if a template ID exists.

Parameters:​

NameTypeDescription
templateIduint256The template ID to check.

Return Values:​

NameTypeDescription
existbooltrue if the template ID exists, false otherwise.

getAllCategoryTemplates​

  function getAllCategoryTemplates(string memory category) external view returns (uint256[] memory)

Retrieves all the template IDs in the given category.

Parameters:​

NameTypeDescription
categorystringThe name of the category.

Return Values:​

TypeDescription
uint256[]An array of all the template IDs in the given category.

getCategoryTemplatesByIndex​

   function getCategoryTemplatesByIndex(
string memory category,
uint16 startIndex,
uint16 batchLength
) external view;

Retrieves a batch of template IDs in the given category, starting from the specified index.

Parameters:​

NameTypeDescription
categorystringThe name of the category.
startIndexuint16The index of the array to start searching from.
batchLengthuint16The length of the returned array.

Return Values:​

TypeDescription
uint256[]An array of template IDs in the given category.

getTemplatesCategory​

function getTemplatesCategory(uint256 templateId) external view returns (string[] memory)

Retrieves the categories that a template belongs to. If the template is not in any category, it will return an empty array.

Parameters:​

NameTypeDescription
templateIdstringThe ID of the template.

Return Values:​

TypeDescription
string[]An array of category names that the template belongs to.

getCategoryTemplateLength​

function getCategoryTemplateLength(string calldata category) external view returns (uint256)

Retrieves the number of templates in a given category.

Parameters:​

NameTypeDescription
categorystringThe name of the category.

Return Values:​

TypeDescription
uint256The length of the category's template list.

getCategoryByName​

function getCategoryByName(
string calldata name
) external view returns (uint256 id, bytes4 selector, string memory uri)

Retrieves the details of a category by its name.

Parameters:​

NameTypeDescription
namestringThe name of the category.

Return Values:​

NameTypeDescription
iduint256The ID of the category.
selectorbytes4Selector of the category.
uristringThe URI of the category.

getCategoryById​

function getCategoryById(uint256 id) external view returns(bytes4 selector, string memory name, string memory uri)

Retrieves the details of a category by its ID.

Parameters:​

NameTypeDescription
iduint256The ID of the category.

Return Values:​

NameTypeDescription
selectorbytes4The selector of the category.
nameuint256The name of the category.
uristringThe URI of the category.

getCategoryBySelector​

function getCategoryBySelector( bytes4 selector) external view returns(uint256 id, string memory name, string memory uri)

Retrieves the details of a category by its selector.

Parameters:​

NameTypeDescription
selectorbytes4The selector of the category.

Return Values:​

NameTypeDescription
iduint256The ID of the category.
nameuint256The name of the category.
uristringThe URI of the category.

Events​

TemplateCreated​

  event TemplateCreated(
uint256 templateId, string uri
);

Emitted when a template is created

Parameters:​

NameTypeDescription
templateIdsuint256Template IDs
uristringTemplate URIs

CategoryCreated​

  event CategoryCreated(string category, uint256 id, bytes4 selector, string uri);

Emitted when a new category is created.

Parameters:​

NameTypeDescription
categorystringThe name of the category.
iduint256The ID of the category.
selectorbytes4The selector of the category.
uristringThe URI of the category.

CategoriesSet​

  event CategoriesSet(string category, uint256[] templateIds);

Emitted when categories are set for a group of templates.

Parameters:​

NameTypeDescription
categorystringThe name of the category.
templateIdsuint256[]The IDs of the templates associated with the category.

CategoryRemoved​

 event CategoryRemoved(string category, uint256 templateId);

Emitted when a template is removed from a category.

Parameters:​

NameTypeDescription
categorystringThe name of the category.
templateIduint256The ID of the removed template.