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:
Name | Type | Description |
---|
uri | string | The 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:
Name | Type | Description |
---|
uris | string[] | 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:
Name | Type | Description |
---|
name | string | The name of the new category. |
uri | string | The 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:
Name | Type | Description |
---|
name | string[] calldata | The name of the new category. |
uri | string[] calldata | The 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:
Name | Type | Description |
---|
category | string | The category name for the templates (e.g., "vehicle"). |
templateIds | string | An 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:
Name | Type | Description |
---|
category | string | The category name for the template. |
templateId | uint256 | The 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:
Name | Type | Description |
---|
templateId | uint256 | Template ID |
Return Values:
Type | Description |
---|
string | Template's URI |
function getProjectSlotPrice(uint256 projectId) external view returns (uint256)
Returns project's slot's price.
Parameters:
Name | Type | Description |
---|
projectId | uint256 | Project ID |
Return Values:
Type | Description |
---|
uint256 | Project'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:
Type | Description |
---|
uint256 | The total number of templates that have been created. |
function getProjectSlotPrice(uint256 projectId) external view returns (uint256)
Returns project's slot's price.
Parameters:
Name | Type | Description |
---|
projectId | uint256 | Project ID |
Return Values:
Type | Description |
---|
uint256 | Project's Slot Price |
isTemplateIdExist
function isTemplateIdExist(uint256 templateId) external view returns (bool exist)
Checks if a template ID exists.
Parameters:
Name | Type | Description |
---|
templateId | uint256 | The template ID to check. |
Return Values:
Name | Type | Description |
---|
exist | bool | true 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:
Name | Type | Description |
---|
category | string | The name of the category. |
Return Values:
Type | Description |
---|
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:
Name | Type | Description |
---|
category | string | The name of the category. |
startIndex | uint16 | The index of the array to start searching from. |
batchLength | uint16 | The length of the returned array. |
Return Values:
Type | Description |
---|
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:
Name | Type | Description |
---|
templateId | string | The ID of the template. |
Return Values:
Type | Description |
---|
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:
Name | Type | Description |
---|
category | string | The name of the category. |
Return Values:
Type | Description |
---|
uint256 | The 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:
Name | Type | Description |
---|
name | string | The name of the category. |
Return Values:
Name | Type | Description |
---|
id | uint256 | The ID of the category. |
selector | bytes4 | Selector of the category. |
uri | string | The 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:
Name | Type | Description |
---|
id | uint256 | The ID of the category. |
Return Values:
Name | Type | Description |
---|
selector | bytes4 | The selector of the category. |
name | uint256 | The name of the category. |
uri | string | The 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:
Name | Type | Description |
---|
selector | bytes4 | The selector of the category. |
Return Values:
Name | Type | Description |
---|
id | uint256 | The ID of the category. |
name | uint256 | The name of the category. |
uri | string | The URI of the category. |
Events
TemplateCreated
event TemplateCreated(
uint256 templateId, string uri
);
Emitted when a template is created
Parameters:
Name | Type | Description |
---|
templateIds | uint256 | Template IDs |
uri | string | Template URIs |
CategoryCreated
event CategoryCreated(string category, uint256 id, bytes4 selector, string uri);
Emitted when a new category is created.
Parameters:
Name | Type | Description |
---|
category | string | The name of the category. |
id | uint256 | The ID of the category. |
selector | bytes4 | The selector of the category. |
uri | string | The URI of the category. |
CategoriesSet
event CategoriesSet(string category, uint256[] templateIds);
Emitted when categories are set for a group of templates.
Parameters:
Name | Type | Description |
---|
category | string | The name of the category. |
templateIds | uint256[] | 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:
Name | Type | Description |
---|
category | string | The name of the category. |
templateId | uint256 | The ID of the removed template. |