Create Clustered Spore
In this recipe, you’ll learn how to tag a Cluster when creating a Spore. If you are looking to create standalone spores (spores without cluster) refer to: Create a Spore.
caution
- You can only utilize a Cluster as a tag if it can be unlocked by you to use.
- You cannot tag a Spore after its creation; you'll need to melt and then tag it during the creation process.
- Each Spore can be associated with only one Cluster.
Your target cluster can be either a public cluster or a private cluster, depending on its lock script.
Create Clustered Spore With ClusterID
You can tag a spore with a cluster by specifying the data.clusterId
when calling the createSpore
API from spore-sdk:
import { createSpore } from '@spore-sdk/core';
let { txSkeleton } = await createSpore({
data: {
contentType: CONTENT_MIME_TYPE,
content: CONTENT_AS_BYTES,
clusterId: CLUSTER_ID,
},
toLock: OWNER_LOCK,
fromInfos: [SPONSOR_ADDRESS],
});
data.clusterId
- The ID of the cluster to be assigned to the spore. The cluster's ID is equivalent to the type script args of the cluster.
Code example
Create Clustered Spore With Cluster Agent
You can tag a spore with a cluster by referencing ClusterAgent
when calling the createSpore
API from spore-sdk:
import { createSpore } from '@spore-sdk/core';
let { txSkeleton, outputIndex } = await createSpore({
data: {
contentType: CONTENT_MIME_TYPE,
content: CONTENT_AS_BYTES,
clusterId: CLUSTER_ID,
},
clusterAgentOutPoint,
toLock: OWNER_LOCK,
fromInfos: [SPONSOR_ADDRESS],
});
data.clusterId
- The ID of the cluster to be assigned to the spore. The cluster's ID is equivalent to the type script args of the cluster.clusterAgentOutPoint
- TheClusterAgent
you want to reference in the transaction
Code example
Was this page helpful?