Create Private Cluster
A cluster is like a on-chain organizing tool that groups spores together. In the recipe, you will learn how to create a private cluster that is secured by an owner lock and requires signature verification to unlock. E.g., the CKB default lock
.
You can also create a public cluster that anyone can pay an unlocking fee to tag spores with it. To learn more about it, please refer to: Creating a Public Cluster.
Create a Private Cluster
You can create a private cluster with the createCluster
API from spore-sdk:
import { createCluster } from '@spore-sdk/core';
let { txSkeleton } = await createCluster({
data: {
name: 'Name of the cluster',
description: 'Description of the cluster',
},
toLock: OWNER_LOCK,
fromInfos: [ONWER_ADDRESS],
});
data
- The cluster's data, including name and description.toLock
- The lock script specifies the new cluster's ownership.fromInfos
- The transaction's sponsors, specifies where to collect capacity from.
Extras
Code example
A cluster creation transaction involves 3 steps: construct, sign, and send. This recipe focuses on the transaction construction. For a valid on-chain transaction, you'll need to sign the transaction and send it to the chain.
Here's a code example for how to create a cluster using CKB default lock
:
Immortal by design
Clusters are immortal by design, it means all clusters, once created, exist permanently on-chain, and not even their owner can destroy them from the blockchain.