Methods
# async createCollection(payload) → {CreateCollectionResponse}
Create collection data
Parameters:
Name | Type | Description |
---|---|---|
payload |
CreateCollectionParams
|
Create collection request params (name / collectionImageUrl / description / contractAddress / metadataUrl) |
Exception: StarkKey is required
string
Exception: Name is required
string
Exception: ContractAddress is required
string
Exception: MetadataAPIUri is required
string
Exception: OwnerPublicKey is required
string
Exception: ProjectID is required
string
Exception: Create Collection failure with internal server error
string
Collection details response
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const contractAddress: string = config.collection_contract_address;
const metadataApiUrl: string = config.metadata_api_url;
const publicKey: string = config.public_key;
const projectId: number = config.project_id;
const starkKey: string = config.stark_key;
const params: CreateCollectionParams = {
name: "Test Collection 1",
description: "Collection Test with SDK",
contractAddress: contractAddress,
metadataApiUrl: metadataApiUrl,
ownerPublicKey: publicKey,
projectId: projectId,
starkKey: starkKey,
};
console.log("Creating the collection...");
const collectionResponse: CreateCollectionResponse = await collectionManager.createCollection(params);
console.log("Created collection response:");
console.log(JSON.stringify(collectionResponse, null, 2));
# async createCollectionByApiKey(payload) → {CreateCollectionResponse|undefined}
Create the collection by using myria user ID and api key
Parameters:
Name | Type | Description |
---|---|---|
payload |
CreateCollectionByApiKeyParams
|
create Collection request params (name,collectionImageUrl?,description?,iconUrl?,contractAddress,ownerPublicKey,metadataApiUrl,projectId,accountId,apiKey) |
Exception: Collection name is required
string
Exception: Contract address is required
string
Exception: Owner PublicKey is required
string
Exception: metadataApiUrl is required
string
Exception: Project ID is required
string
Exception: ApiKey is required
string
Exception: Myria User ID is required
string
Exception: Create project failed with internal server error
string
Collection information data
CreateCollectionResponse
|
undefined
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const params: CreateCollectionByApiKeyParams = {
name: name_Collection;
collectionImageUrl?: 'abc.png';
description?: description;
iconUrl?: abc.png;
contractAddress: contractAddress;
ownerPublicKey: Owner PublicKey;
metadataApiUrl: metaDataApiURL;
projectId: 1;
accountId: accountId;
apiKey: APIKey
};
console.log("Create the Collection...");
const newCollectionResponse: CreateCollectionResponse = await collectionManager.createCollectionByApiKey(params);
console.log("Created Collection response:");
console.log(JSON.stringify(newCollectionResponse, null, 2));
# async createCollectionMetadataByAddress(contractAddress, payload) → {CollectionDetailsResponseData}
Create collection metadata schema by smart contract address (deployed address of the collection contract)
Parameters:
Name | Type | Description |
---|---|---|
contractAddress |
string
|
Smart contract address of the collection |
payload |
CreateCollectionMetadataParams
|
The metadata structure params |
Exception: Contract address is required
string
Exception: StarkKey is required
string
Exception: Key name of metadata is required
string
Exception: Internal server error
string
List of metadata fields of the specific collection
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const contractAddress = '0xFCB75a9De034b9DEff9aD1a12142c12E51665F97';
const payload: CreateCollectionMetadataParams = {
metadata: [
{
name: 'rarity',
type: 'string',
filterable: true,
},
{
name: 'power',
type: 'string',
filterable: true,
},
{
name: 'level',
type: 'enum',
filterable: true,
},
{
name: 'color',
type: 'string',
filterable: false,
},
];
starkKey: '0xFC....',
};
console.log("Get the collection metadata...");
const collectionMetadata: CollectionDetailsResponseData = await collectionManager.createCollectionMetadataByAddress(contractAddress, payload);
console.log(JSON.stringify(collectionMetadata, null, 2));
# async getAssetByCollectionId(payload) → {CommonPaginateDataTypes.<Array.<AssetListResponse>>}
Get the asset list by collection ID
Parameters:
Name | Type | Description |
---|---|---|
payload |
GetAssetByCollectionParams
|
The request params for querying the list of the assets |
Exception: The collectionID is required
string
Exception: The assetType is required
string
The paginated data response (including the list of the assets)
CommonPaginateDataTypes.<Array.<AssetListResponse>>
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const payload: GetAssetByCollectionParams = {
collectionId: 1,
assetType: 'NON_SALE',
limit: 100,
page: 1
};
console.log("Get asset list by collection ID");
const assetsData: CommonPaginateDataTypes<AssetListResponse[]> = await collectionManager.getAssetByCollectionId(payload);
console.log(JSON.stringify(assetsData, null, 2));
# async getCollectionById(id) → {CollectionDetailsResponseData}
Get collection details by ID
Parameters:
Name | Type | Description |
---|---|---|
id |
number
|
unique ID of the collection |
Exception: Collection ID is required
string
Exception: Get collection by ID failed with internal server error
string
Collection details information data
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const collectionId = 1;
console.log("Get the collection...");
const collectionData: CollectionDetailsResponseData = await collectionManager.getCollectionById(collectionId);
console.log(JSON.stringify(collectionData, null, 2));
# async getCollectionByPublicId(publicId) → {CollectionDetailsResponseData}
Get the collection by the public ID (uuid)
Parameters:
Name | Type | Description |
---|---|---|
publicId |
string
|
The unique public ID (UUID) of the collection |
Exception: The public ID is required
string
Collection details information data (metadata schema, name, description, metadataUrl...)
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const publicId = 'f1d203eb-cd15-49ff-8852-41846a508bd8'; // unique UUID of the collection
console.log("Get collection by public ID...");
const collectionData: CollectionDetailsResponseData = await collectionManager.getCollectionByPublicId(publicId);
console.log(JSON.stringify(collectionData, null, 2));
# async getCollectionList(GetCollectionParams) → {CommonPaginateDataTypes.<Array.<CollectionListResponse>>}
Get collection list
Parameters:
Name | Type | Description |
---|---|---|
GetCollectionParams |
GetCollectionParams
|
query collections params |
Paginable collections data
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const params: GetCollectionParams = {
limit: 10,
page: 1,
isHot: true
};
console.log("Get the collection...");
const collections: CommonPaginateDataTypes<CollectionListResponse[]> = await collectionManager.getCollectionList(params);
console.log("List of collection response:");
console.log(JSON.stringify(collections, null, 2));
# async getCollectionMetadataByAddress(contractAddress) → {Array.<CollectionMetadataSchemaParams>}
Get collection metadata schema by smart contract address (deployed address of the collection)
Parameters:
Name | Type | Description |
---|---|---|
contractAddress |
string
|
The smart contract address of the collection |
Exception: Contract address is required
string
List of metadata fields of the specific collection
Array.<CollectionMetadataSchemaParams>
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const contractAddress = '0xFCB75a9De034b9DEff9aD1a12142c12E51665F97';
console.log("Get the collection metadata...");
const collectionMetadata: APIResponseType<CollectionMetadataSchemaParams[]> = await collectionManager.getCollectionMetadataByAddress(contractAddress);
console.log(JSON.stringify(collectionMetadata, null, 2));
# async getTotalPurchasedAssetsGroupedByUser(totalPurchasedAssets) → {CommonPaginateDataTypes.<Array.<OwnerAssetsCount>>}
Get total purchased assets group by user
Parameters:
Name | Type | Description |
---|---|---|
totalPurchasedAssets |
GetTotalAssetsByOwnerParams
|
Request for query total assets by owner params |
Exception: CollectionId is required
string
Exception: Stark key is required
string
Exception: Internal server error
string
Exception: Get list failed: ${err}
string
owner assets count result
CommonPaginateDataTypes.<Array.<OwnerAssetsCount>>
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const payload: GetTotalAssetsByOwnerParams = {
collectionId: 1,
starkKey: '0xFA....'
};
console.log("Get total purchased assets group by users");
const ownerData: CommonPaginateDataTypes<OwnerAssetsCount[]> = await collectionManager.getTotalPurchasedAssetsGroupedByUser(payload);
console.log(JSON.stringify(ownerData, null, 2));
# async updateCollectionByCollectionIdAndApiKey(payload) → {CollectionDetailsResponseData}
Update collection by contract address and partner api key
Parameters:
Name | Type | Description |
---|---|---|
payload |
UpdateCollectionByCollectionIdAndApiKeyParams
|
The updated collection requests params |
Exception: Contract Address is required
string
Exception: Stark key is required
string
Exception: Myria account ID is required
string
The collection details information
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const payload: UpdateCollectionByCollectionIdAndApiKeyParams = {
collectionId: '1', // Number string
name: 'New name of the collection',
accountId: '0xabc...',
apiKey: '0x1acd...', // Partner API key
description: 'New description of collection',
collectionImageUrl: 'https://collection-banner-url.com'
iconUrl: 'https://icon-avatar-collection.com'
};
console.log("Update collection by smart contract address");
const collectionData: CollectionDetailsResponseData = await collectionManager.updateCollectionByCollectionIdAndApiKey(payload);
console.log(JSON.stringify(collectionData, null, 2));
# async updateCollectionByContractAddress(payload) → {CollectionDetailsResponseData}
Update collection by contract address and stark key
Parameters:
Name | Type | Description |
---|---|---|
payload |
UpdateCollectionByContractAddressParams
|
The updated collection requests params |
Exception: Contract Address is required
string
Exception: Stark key is required
string
Exception: Internal server error
string
The collection details information
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const payload: UpdateCollectionByContractAddressParams = {
contractAddress: '0xFC...',
name: 'New name of the collection',
starkKey: '0xabc...',
description: 'New description of collection',
collectionImageUrl: 'https://collection-banner-url.com'
iconUrl: 'https://icon-avatar-collection.com'
};
console.log("Update collection by smart contract address");
const collectionData: CollectionDetailsResponseData = await collectionManager.updateCollectionByContractAddress(payload);
console.log(JSON.stringify(collectionData, null, 2));
# async updateCollectionMetadataByAddress(contractAddress, name, payload) → {CollectionDetailsResponseData}
Update metadata schema (change field key) by smart contract address
Parameters:
Name | Type | Description |
---|---|---|
contractAddress |
string
|
The unique smart contract address for the collection |
name |
string
|
The existing key property in the metadata schema (for example we have the property power, and we want to change to power_character) |
payload |
UpdateCollectionMetadataParams
|
The request params for Updated Metadata |
Exception: Internal server error
string
The collection details information (including new metadata updated...)
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const contractAddress = '0xFCB75a9De034b9DEff9aD1a12142c12E51665F97';
const name = 'Rarity';
const payload: UpdateCollectionMetadataParams = {
name: 'Rarity_1',
type: 'string',
filterable: true,
starkKey: '0x09af....'
};
console.log("Update the collection metadata by smart contract address...");
const collectionData: CollectionDetailsResponseData = await collectionManager.updateCollectionMetadataByAddress(contractAddress, name, payload);
console.log(JSON.stringify(collectionData, null, 2));
# async validateMetadata(payload) → {ValidateMetadataResponse}
Validate the metadata with metadataSchema and metaData URL test
Parameters:
Name | Type | Description |
---|---|---|
payload |
ValidateMetadataParams
|
The updated collection requests params |
Exception: Metadata Schema is required
string
Exception: Asset Metadata Url is required
string
Http Status Code 500: Validate metadata failed with internal server error
string
The collection details information
Example
const collectionManager: CollectionManager = new CollectionManager(EnvTypes.STAGING);
const payload: ValidateMetadataParams = {
metadata: [
{
"name": "type",
"type": "string",
"filterable": true
},
{
"name": "rarity",
"type": "string",
"filterable": true
}
],
"assetMetadataUri": "https://myria.com/v1/sigil/metadata/1"
};
console.log("Validate Metadata by metadata url and metadataSchema");
const validateMetadataRespond: CollectionDetailsResponseData = await collectionManager.validateMetadata(payload);
console.log(JSON.stringify(validateMetadataRespond, null, 2));