Skip to main content

Melt Cluster Proxy/Agent

In this recipe, you will learn how to melt a cluster proxy and a cluster agent back into its locked up CKBytes.

caution

Clusters cannot be melted.

Melt a Cluster Proxy

You can melt a cluster proxy using the meltClusterProxy API from spore-sdk:

import { meltClusterProxy, getClusterProxyById } from '@spore-sdk/core';

const clusterProxyCell = await getClusterProxyById('0x<cluster_proxy_id>');

let { txSkeleton } = await meltClusterProxy({
outPoint: clusterProxyOutPoint,
changeAddress: CHANGE_ADDRESS,
});
  • outPoint - Specifies the cluster proxy you want to melt, identified by its hash and index.
  • changeAddress - Specifies the destination address for receiving the capacity released from a melted spore. If not specified, the capacity will be returned to the cluster proxy's owner.

Melt a Cluster Agent

You can melt a cluster agent using the meltClusterAgent API from spore-sdk:

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

let { txSkeleton } = await meltClusterAgent({
outPoint: {
txHash: '0x<transaction_hash>',
index: '0x<cluster_agent_output_index>',
},
changeAddress: CHANGE_ADDRESS,
});
  • outPoint - Specifies the cluster proxy you want to melt, identified by its transaction hash and index.
  • changeAddress - Specifies the destination address for receiving the capacity released from a melted spore. If not specified, the capacity will be returned to the cluster proxy's owner.

Extras

Code examples

For a valid on-chain transaction, you'll need to sign the transaction skeleton and send it to the chain.

Here are code examples for how to melt cluster proxy and cluster agent using CKB default lock:

meltClusterProxy.ts
Melt a ClusterProxy
https://github.com/sporeprotocol/spore-sdk/blob/beta/examples/secp256k1/apis/meltClusterProxy.ts
meltClusterAgent.ts
Melt a ClusterAgent
https://github.com/sporeprotocol/spore-sdk/blob/beta/examples/secp256k1/apis/meltClusterAgent.ts