Create Collection with platform contract
get started with one of phosphor's platform contracts
Create a new collection with a custom contract (BYOC)
Use your own smart contract to create a new collection (with restrictions)
Create a new collection with a External contract
Use an external smart contract to create a new collection (with restrictions)
async function createCollection(data) {
const {
name,
description,
deploymentRequest,
defaultItemTypeId,
editableMetadata,
externalLink,
imageUrl,
isPublic,
media,
previewMetadata,
revealStrategy,
} = data;
const {
networkId,
platform: { variant, symbol, maxSupply, salt, owner },
} = deploymentRequest;
try {
const headers = new Headers();
headers.append("Content-Type", "application/json");
// Add the Phosphor API key to the headers like this
headers.append("Phosphor-Api-Key", phosphorApiKey);
return fetch(`${phosphorApiUrl}/v1/collections`, {
method: "POST",
headers,
body: JSON.stringify({
name,
description,
media: {
header_image_url: media?.headerImageUrl,
thumbnail_image_url: media?.thumbnailImageUrl,
},
external_link: externalLink,
deployment_request: {
// network id that is supported by Phosphor
network_id: networkId,
type: "PLATFORM",
token_id_assignment_strategy: variant.tokenIDAssignmentStrategy,
platform: {
variant: variant.name,
maxSupply,
salt,
symbol,
owner,
},
},
is_public: isPublic,
preview_metadata: previewMetadata,
default_item_type_id: defaultItemTypeId,
editable_metadata: editableMetadata,
image_url: imageUrl,
reveal_strategy: revealStrategy,
}),
});
} catch (error) {
console.log(error);
}
}