Skip to main content

Transfer Cluster Agent

In this recipe, you will learn how to transfer ownership of a cluster agent using the spore-sdk. Owning a cluster agent doesn’t grant ownership of the referenced cluster proxy or the associated cluster.

Transfer a Cluster Agent

You can execute a transfer using the transferClusterAgent API from spore-sdk:

import { transferClusterAgent } from '@spore-sdk/core';

let { txSkeleton } = await transferClusterAgent({
outPoint: {
txHash: '0x<transaction_hash>',
index: '0x<cluster_agent_output_index>',
},
fromInfos: [SPONSOR_ADDRESS]
toLock: RECEIVER_LOCK_SCRIPT,
});
  • outPoint - Specifies the target cluster agent for the transfer, identified by its transaction hash and index.
  • fromInfos - The transaction's sponsors, specifies where to collect capacity from.
  • toLock - The lock script of the new owner/recipient of the cluster agent.

Extras

Code example

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 transfer a cluster agent with CKB default lock:

transferClusterAgent.ts
Transfer a Cluster Agent
https://github.com/sporeprotocol/spore-sdk/blob/beta/examples/secp256k1/apis/transferClusterAgent.ts