Create Cluster Agent
Cluster Proxy and Cluster Agents offer a solution to verify ownership when referencing a cluster during simultaneous spore creation.
You will learn how to create a Cluster Agent, which serves as a representative for a Cluster. This enables the creation of clustered spores without requiring the signatures or approvals from the owner of the Cluster being represented.
Create a Cluster Agent
Method 1
You can create a Cluster Agent by referencing a ClusterProxy with the createClusterAgent
API from spore-sdk:
import { createClusterAgent } from '@spore-sdk/core';
const referencedClusterProxyOutPoint: OutPoint = {
txHash: '0x...',
index: '0x...',
};
// Two methods to create a ClusterAgent
// 'cell' - Reference ClusterProxy in the transaction
// 'payment' - Pay the owner of the ClusterProxy in the transaction
const referenceType: 'cell' | 'payment' = 'cell';
const { txSkeleton, reference } = await createClusterAgent({
clusterProxyOutPoint: referencedClusterProxyOutPoint,
referenceType: referenceType,
fromInfos: [SPONSOR_ADDRESS],
toLock: OWNER_LOCK,
});
clusterProxyOutPoint
- Specifies the OutPoint data of the target ClusterProxy for creating the ClusterAgent.fromInfos
- The transaction's sponsors, specifies where to collect capacity from.toLock
- The lock script that specifies the ClusterAgent's ownership.
Method 2
You can create a Cluster Agent by paying to the owner of the ClusterProxy
with the createClusterAgent
API from spore-sdk:
import { createClusterAgent } from '@spore-sdk/core';
import { BI } from '@ckb-lumos/bi';
const referencedClusterProxyOutPoint: OutPoint = {
txHash: '0x...',
index: '0x...',
};
// Two methods to create a ClusterAgent
// 'cell' - Reference ClusterProxy in the transaction
// 'payment' - Pay the owner of the ClusterProxy in the transaction
const referenceType: 'cell' | 'payment' = 'payment';
// The amount of shannons pay to the owner of the ClusterProxy,
// the amount will be `10^minPayment` required by the ClusterProxy.
// optional, if undefined.
const paymentAmount: BIish = BI.from(100_0000_0000);
const { txSkeleton, reference } = await createClusterAgent({
clusterProxyOutPoint: referencedClusterProxyOutPoint,
referenceType: referenceType,
paymentAmount: n,
fromInfos: [SPONSOR_ADDRESS],
toLock: OWNER_LOCK,
});
clusterProxyOutPoint
- Specifies the OutPoint data of the target ClusterProxy for creating the ClusterAgent.fromInfos
- The transaction's sponsors, specifies where to collect capacity from.toLock
- The lock script that specifies the ClusterAgent's ownership.paymentAmount
- The amount of shannons pay to the owner of the ClusterProxy. Optional, if undefined. If defined, the amount will be 10^minPayment shannons required by the ClusterProxy.
Extras
Code example
Data Structure
Cluster Agent Cell:
Data: Type Hash of Referenced Cluster Proxy
Type:
code_hash: CLUSTER_AGENT_TYPE_HASH
args: REFERENCED_CLUSTER_ID
Lock:
<user_defined>
Was this page helpful?