Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ckb-devrel/ccc/llms.txt

Use this file to discover all available pages before exploring further.

The examples below cover common CKB operations. Each links to the CCC Playground so you can run and modify them instantly in your browser.

Transfer Native CKB

Send CKB to an address. Shows how to build and complete a transaction with automatic fee calculation.

Transfer All CKB

Transfer all native CKB from your wallet, leaving no dust behind.

Sign and Verify

Sign a message with a signer and verify the signature using the unified CCC interface.

Transfer UDT

Transfer a User Defined Token (UDT) to another address on CKB.

Custom UI

Build a wallet connection UI targeting a specific wallet, without using the default connector component.

Custom UI with Controller

Use all supported wallets in a fully custom UI with the CCC controller API.

Transfer Native CKB

The full source for the transfer example:
import { ccc } from "@ckb-ccc/ccc";
import { render, signer } from "@ckb-ccc/playground";

// The receiver is the signer itself on mainnet
const receiver = await signer.getRecommendedAddress();
console.log(receiver);

// Parse the receiver script from an address
const { script: lock } = await ccc.Address.fromString(receiver, signer.client);

// Describe what we want
const tx = ccc.Transaction.from({
  outputs: [{ capacity: ccc.fixedPointFrom(100), lock }],
});
await render(tx);

// Complete missing parts: Fill inputs
await tx.completeInputsByCapacity(signer);
await render(tx);

// Complete missing parts: Pay fee
await tx.completeFeeBy(signer);
await render(tx);
Run in Playground The transaction composing pattern is simple:
  1. Define outputs (what you want to send).
  2. Call completeInputsByCapacity to automatically select inputs.
  3. Call completeFeeBy to compute and attach the fee.
  4. Send with signer.sendTransaction(tx).

Sign and Verify a Message

import { ccc } from "@ckb-ccc/ccc";
import { client, signer as playgroundSigner } from "@ckb-ccc/playground";

// The default signer can not sign message
// Create a new one when needed
const signer: ccc.Signer =
  playgroundSigner instanceof ccc.SignerCkbPublicKey
    ? new ccc.SignerCkbPrivateKey(client, "01".repeat(32))
    : playgroundSigner;
const message = "Hello world";

// Sign message
const signature = await signer.signMessage("Hello world");
console.log(signature);

console.log(
  `Verification should pass: ${await ccc.Signer.verifyMessage(message, signature)}`,
);
console.log(
  `Verification should fail: ${await ccc.Signer.verifyMessage("Wrong message", signature)}`,
);
Run in Playground ccc.Signer.verifyMessage works across all supported wallet types — no need to handle each chain’s signature format manually.

Build docs developers (and LLMs) love