Skip to main content

Collections Reference

This document is a reference to the Collections module of the Myria Core SDK. The module contains information about Myria collections.

Interfaces

CreateCollectionParams

Data structure passed to createCollection() method, which contains required data to create a new collection.

interface CreateCollectionParams {
name: string;
collectionImageUrl?: string;
description?: string;
iconUrl?: string;
contractAddress: string;
ownerPublicKey: string;
metadataApiUrl: string;
starkKey: string;
projectId: number;
}

Attributes

  • name- collection name
  • collectionImageUrl - url for main collection image
  • description - collection description
  • iconUrl - url for collection icon
  • contractAddress - contract address used to withdraw assets to the Ethereum network
  • ownerPublicKey - public key of the collection owner
  • metadataApiUrl - api url that will store collection metadata
  • starkKey - Stark Key, has to start with 0x
  • projectId - project id of the collection

CreateCollectionResponse

Data structure returned by the createCollection() method.

interface CreateCollectionResponse {
id: number;
createdAt: string;
updatedAt: string;
name: string;
collectionImageUrl: string;
description: string;
iconUrl: string;
contractAddress: string;
ownerPublicKey: string;
metadataApiUrl: string;
starkKey: string;
pubicId: string;
}

Attributes

  • id - collection id
  • createdAt - when the collection was created
  • updatedAt - when the collection was updated last time
  • name- collection name
  • collectionImageUrl - url for main collection image
  • description - collection description
  • iconUrl - url for collection icon
  • contractAddress - contract address used to withdraw assets to the Ethereum network
  • ownerPublicKey - public key of the collection owner
  • metadataApiUrl - api url that will store collection metadata
  • starkKey - Stark Key, has to start with 0x
  • pubicId - public id of the collection

GetCollectionParams

Data structure passed to getCollectionList() method, which contains required parameters for querying collections.

interface GetCollectionParams {
limit?: number;
page?: number;
isHot?: boolean;
}

Attributes

  • limit - the max number of collections to return per response
  • page- the page number of returned collections based on the defined limit
  • isHot - whether the collection should be included in the hot section on the marketplace

CollectionDetailsResponse

Data structure that contains collection details response.

interface CollectionDetailsResponse {}

CollectionDetailsResponseData

Data structure that contains collection details response data.

interface CollectionDetailsResponseData {
id: number;
createdAt: string;
updatedAt: string;
name: string;
collectionImageUrl: string;
description: string;
iconUrl: string;
contractAddress: string;
ownerPublicKey: string;
metadataApiUrl: string;
starkKey: string;
publicId: string;
metadataSchema: any[];
project: ProjectResponseData;
}

Attributes

  • id - collection id
  • createdAt - when the collection was created
  • updatedAt - when the collection was updated last time
  • name- collection name
  • collectionImageUrl - url for main collection image
  • description - collection description
  • iconUrl - url for collection icon
  • contractAddress - contract address used to withdraw assets to the Ethereum network
  • ownerPublicKey - public key (wallet address) of the collection owner
  • metadataApiUrl - api url that will store collection metadata
  • starkKey - Stark Key, has to start with 0x
  • publicId - public id of the collection
  • metadataSchema - an array of MetaDataShema
  • project - ProjectResponseData object

CollectionListResponse

Data structure returned by the getCollectionList() method.

interface CollectionListResponse {
id: number;
createdAt: string;
updatedAt: string;
name: string;
collectionImageUrl: string;
description: string;
iconUrl: null;
contractAddress: string;
ownerPublicKey: string;
metadataApiUrl: string;
starkKey: string;
publicId: string;
isHot: boolean;
metadataSchema: MetaDataSchema[];
project: ProjectResponseData;
}

Attributes

  • id - collection id
  • createdAt - when the collection was created
  • updatedAt - when the collection was updated last time
  • name- collection name
  • collectionImageUrl - url for main collection image
  • description - collection description
  • iconUrl - url for collection icon
  • contractAddress - contract address used to withdraw assets to the Ethereum network
  • ownerPublicKey - public key of the collection owner
  • metadataApiUrl - api url that will store collection metadata
  • starkKey - Stark Key, has to start with 0x
  • publicId - public id of the collection
  • isHot - whether the collection should be included in the hot section on the marketplace
  • metadataSchema - an array of MetaDataShema
  • project - ProjectResponseData object

MetaDataSchema

Data structure that contains metadata schema each item in the collection will follow.

interface MetaDataSchema {
god: string;
name: string;
type: number;
attack: number;
rarity: number;
element: string;
product: number;
imageUrl: string;
collectable: true;
animationUrl: string;
animationUrlMimeType: string;
}

CollectionMetadataSchemaParams

Data structure passed to createCollectionMetadataByAddress() method, which contains required data for creating a metadata schema field.

interface CollectionMetadataSchemaParams {
name: string;
type?: string;
filterable?: boolean;
}

CollectionMetadataResponse

Data structure returned by the getCollectionMetadataByAddress() method.

interface CollectionMetadataResponse {
name: string;
type?: string;
filterable?: boolean;
}

Attributes

  • name- metadata schema field name
  • type - metadata schema field type
  • filterable - whether a field should be filterable in the marketplace

CreateCollectionMetadataResponseType

Data structure that contains an array of metadata schema fields.

interface CreateCollectionMetadataResponseType {
metadata: any[];
}

Attributes

  • metadata - metadata schema fields

Methods

createCollection()

Creates a collection.

Parameters

Returns

Returns a collection object.

createCollection(payload: CreateCollectionParams): Promise<CreateCollectionResponse | undefined>;

Returns

import { CollectionManager, CreateCollectionParams, CreateCollectionResponse, EnvTypes } from "myria-core-sdk";

(async (): Promise<void> => {
// STAGING or PRODUCTION
const env = EnvTypes.STAGING;

const collectionManager: CollectionManager = new CollectionManager(env);

const params: CreateCollectionParams = {
name: "COLLECTION_NAME",
description: "COLLECTION_DESCRIPTION",
contractAddress: "CONTRACT_ADDRESS",
metadataApiUrl: "METADATA_API_URL",
ownerPublicKey: "OWNER_PUBLIC_KEY",
projectId: "PROJECT_ID",
starkKey: "STARK_KEY",
};

const newCollectionResponse: CreateCollectionResponse | undefined =
await collectionManager.createCollection(params);
})();

Response

CreateCollectionResponse
{
"id": 19,
"createdAt": "2022-07-12T10:10:22.192Z",
"updatedAt": "2022-07-12T10:10:22.192Z",
"name": "MT Collection",
"collectionImageUrl": null,
"description": "MT original",
"iconUrl": null,
"contractAddress": "0x365bdeE115b3Ad192a494FDa6a4d18E79fdf03Af",
"ownerPublicKey": "0x75e0D99fa416823F4C07CDafC86A3B0cA37B52A5",
"metadataApiUrl": "https://gateway.pinata.cloud/ipfs/QmSjWbBS3rPu5K2TnhyXmwGE1GcVZMRFKg5K3iMLGca1m8",
"starkKey": "0x43be26f8a75d1fc532a871ed88561f75fadd1a901b4fed01d0c8ef48762f1a9",
"publicId": "24dd6da6-e129-4e4f-ab01-a4408649f3bd",
"isHot": false,
"metadataSchema": [],
"project": {
"id": 33,
"createdAt": "2022-07-07T11:28:14.731Z",
"updatedAt": "2022-07-12T10:10:22.213Z",
"name": "Test Game",
"companyName": "Gaming Studio X",
"contactEmail": "test@google.com",
"collectionLimitExpiresAt": "2022-08-08T15:07:01.266Z",
"collectionMonthlyLimit": 5,
"collectionRemaining": 3,
"mintLimitExpiresAt": null,
"mintMonthlyLimit": 50000,
"mintRemaining": 50000,
"publicId": "3a81b6f4-821e-48ae-bcd5-0d99533c9136",
"__entity": "ProjectEntity"
},
"__entity": "CollectionEntity"
}

getCollectionList()

Returns a list of collections.

getCollectionList(params?: GetCollectionParams): Promise<APIResponseType<CommonPaginateDataTypes<CollectionListResponse[]>> | undefined>;

Parameters

Returns

Returns an object with response call status and the data object that contains a list of collections.

Returns

import { CollectionManager, GetCollectionParams, EnvTypes } from "myria-core-sdk";

(async (): Promise<void> => {
// STAGING or PRODUCTION
const env = EnvTypes.STAGING;

const params: GetCollectionParams = {
limit: 100,
page: 1,
isHot: false
}

const collectionManager: CollectionManager = new CollectionManager(env);

const collectionListResponse = await collectionManager.getCollectionList(params);
})();

Response

CollectionListResponse[]
{
"status": "success",
"data": {
"items": [
{
"id": 11,
"createdAt": "2022-07-08T05:26:22.733Z",
"updatedAt": "2022-07-08T05:26:22.733Z",
"name": "Myria Mintable ERC721 Collection",
"collectionImageUrl": null,
"description": "This is myria mintable erc20",
"iconUrl": null,
"contractAddress": "0x62a9070a412a10334CA3a64Ade99c08ec9eCCac0",
"ownerPublicKey": "0x518fa612dad02b5d365f4b4b034938d38c39c0e4c94551315da002f00f3824c",
"metadataApiUrl": "https://metadata",
"starkKey": "0x518fa612dad02b5d365f4b4b034938d38c39c0e4c94551315da002f00f3824c",
"publicId": "af5052a3-acf7-4bd9-a7ed-5202d2dff56d",
"isHot": false,
"metadataSchema": [],
"project": {
"id": 1,
"createdAt": "2022-07-05T03:28:34.375Z",
"updatedAt": "2022-07-08T05:26:22.757Z",
"name": "Auto_tester_root_1656991708329",
"companyName": "Myria",
"contactEmail": "test@myria.com",
"collectionLimitExpiresAt": "2022-08-05T05:26:22.410Z",
"collectionMonthlyLimit": 1,
"collectionRemaining": 0,
"mintLimitExpiresAt": null,
"mintMonthlyLimit": 1,
"mintRemaining": 1,
"publicId": "80615e5e-c3a8-45f6-8c68-89d7d82cdf64",
"__entity": "ProjectEntity"
},
"__entity": "CollectionEntity"
},
...
],
"meta": {
"totalItems": 11,
"itemCount": 10,
"itemsPerPage": 10,
"totalPages": 2,
"currentPage": 1
},
"links": {
"first": "http://localhost:8081/v1/collections?limit=10",
"previous": "",
"next": "http://localhost:8081/v1/collections?page=2&limit=10",
"last": "http://localhost:8081/v1/collections?page=2&limit=10"
}
}
}

getCollectionById()

Returns a collection by its id.

getCollectionById(id: number): Promise<CollectionDetailsResponse | undefined>;

Parameters

  • id - collection id

Returns

Returns an object with response call status and the data object that contains information about the project.

Returns

import { CollectionManager, EnvTypes } from "myria-core-sdk";

(async (): Promise<void> => {
// STAGING or PRODUCTION
const env = EnvTypes.STAGING;

const collectionManager: CollectionManager = new CollectionManager(env);

const collectionResponse =
await collectionManager.getCollectionById(COLLECTION_ID);
})();

Response

CollectionDetailsResponse
{
"status": "success",
"data": {
"id": 1,
"publicId": "07767aed-b0a0-4096-9795-ad5846ec7928",
"createdBy": "Myria-Project1",
"description": "Myria Collection in Project 1 description",
"totalAssets": 55,
"totalAssetsForSale": 0
}
}

getCollectionMetadataByAddress()

Returns metadata of the collection.

getCollectionMetadataByAddress(contractAddress: string): Promise<APIResponseType<CollectionMetadataResponse> | undefined>;

Parameters

  • contractAddress - contract address used to withdraw assets to the Ethereum network

Returns

Returns an object with response call status and the data object that contains information about the collection's metadata.

Returns

import { CollectionManager, EnvTypes } from "myria-core-sdk";

(async (): Promise<void> => {
// STAGING or PRODUCTION
const env = EnvTypes.STAGING;

const collectionManager: CollectionManager = new CollectionManager(env);

const collectionResponse =
await collectionManager.getCollectionMetadataByAddress("CONTRACT_ADDRESS");
})();

Response

CollectionMetadataResponse
{
"status": "success",
"data": [
{
"name": "some-metadata-name",
"type": "discrete",
"filterable": true
},
{
"name": "rare",
"type": "boolean",
"filterable": true
}
]
}

getCollectionByPublicId()

Returns a collection by its public id.

getCollectionByPublicId(publicId: string): Promise<APIResponseType<CollectionDetailsResponseData> | undefined>;

Parameters

  • publicId - public id of the collection

Returns

Returns an object with response call status and the data object that contains information about the collection.

Returns

import { CollectionManager, EnvTypes } from "myria-core-sdk";

(async (): Promise<void> => {
// STAGING or PRODUCTION
const env = EnvTypes.STAGING;

const collectionManager: CollectionManager = new CollectionManager(env);

const collectionResponse =
await collectionManager.getCollectionByPublicId(COLLECTION_PUBLIC_ID);
})();

Response

CollectionDetailsResponseData
{
"status": "success",
"data": {
"id": 11,
"createdAt": "2022-07-08T05:26:22.733Z",
"updatedAt": "2022-07-08T05:26:22.733Z",
"name": "Myria Mintable ERC721 Collection",
"collectionImageUrl": null,
"description": "This is myria mintable erc20",
"iconUrl": null,
"contractAddress": "0x62a9070a412a10334CA3a64Ade99c08ec9eCCac0",
"ownerPublicKey": "0x518fa612dad02b5d365f4b4b034938d38c39c0e4c94551315da002f00f3824c",
"metadataApiUrl": "https://metadata",
"starkKey": "0x518fa612dad02b5d365f4b4b034938d38c39c0e4c94551315da002f00f3824c",
"publicId": "af5052a3-acf7-4bd9-a7ed-5202d2dff56d",
"isHot": false,
"metadataSchema": [],
"project": {
"id": 1,
"createdAt": "2022-07-05T03:28:34.375Z",
"updatedAt": "2022-07-08T05:26:22.757Z",
"name": "Auto_tester_root_1656991708329",
"companyName": "Myria",
"contactEmail": "test@myria.com",
"collectionLimitExpiresAt": "2022-08-05T05:26:22.410Z",
"collectionMonthlyLimit": 1,
"collectionRemaining": 0,
"mintLimitExpiresAt": null,
"mintMonthlyLimit": 1,
"mintRemaining": 1,
"publicId": "80615e5e-c3a8-45f6-8c68-89d7d82cdf64",
"__entity": "ProjectEntity"
},
"__entity": "CollectionEntity"
}
}