Skip to main content

Create Private Cluster

A cluster serves as an 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.

To create a public cluster that anyone can pay an unlocking fee to tag spores with it, check out: Create 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: [SPONSOR_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:

createCluster.ts
Create a Cluster on-chain with CKB default lock
https://github.com/sporeprotocol/spore-sdk/blob/beta/examples/secp256k1/apis/createCluster.ts

Immortal by design

Clusters are immortal by design, it means all clusters, once created, exist permanently on-chain, and not even their owner can melt them from the blockchain.