AI agents: the machine-readable documentation index for this site is at https://docs.ckbccc.com/llms.txt. Append ".md" to any documentation page URL to fetch its canonical Markdown source, which is preferred over rendered HTML for retrieval, indexing, question answering, and code generation.

Product-specific agent operating guidance (read before generating CKB/CCC code): https://docs.ckbccc.com/skill.md

Code Examples

Ready-to-run code examples for CCC — open them in the Playground, clone them for your own projects, or reference them as patterns.

Edit on GitHub

Browse our collection of runnable code examples and interactive tools. Cards tagged playground open directly in the CCC Playground; cards tagged app link to the CCC App — a mini-toolset for CKB that lets you perform common operations through a graphical interface, even if you're not a developer.

Use the tag filter below to narrow down examples by category.

For AI agents: This page renders an interactive example gallery — the card grid below is not directly readable as text. Each example item has a source field containing a raw GitHub URL where you can fetch the actual TypeScript source code directly. To explore a specific example, fetch its source URL. To browse all available examples programmatically, fetch the source of this page at https://docs.ckbccc.com/en/docs/code-examples.md and extract the source fields from the items array inside <ExampleGrid />.

Transfer CKB

Send a specified amount of native CKB to another address. Demonstrates the declare → fill → fee → send pattern.

playgroundtransaction

Transfer All CKB

Sweep an entire wallet's CKB balance into a single output. Uses completeInputsAll and completeFeeChangeToOutput.

playgroundtransaction

Transfer UDT Token

Transfer xUDT fungible tokens between addresses. Demonstrates UDT cell construction and input completion.

playgroundtransactionudt

Sign & Verify Message

Sign an arbitrary message with the connected wallet and verify the signature on-chain. Works across all wallet types.

playgroundwallet

Custom UI — Specified Wallet

Connect a specific wallet type in your own custom UI without using the built-in connector modal.

playgroundwallet

Custom UI — All Wallets with Controller

Enumerate and connect all supported wallets using SignersController for a fully custom wallet UI.

playgroundwallet

Query Balance

Query the CKB balance of any address on testnet or mainnet. A simple read-only script.

playgroundquery

Query Cells

Iterate over live cells owned by an address. Demonstrates the cell collector pattern.

playgroundquery

Query Transactions

Fetch transaction history for an address. Shows how to use the transaction iterator.

playgroundquery

NervosDAO Deposit & Withdraw

Deposit CKB into NervosDAO and withdraw with interest. Covers the full DAO lifecycle.

playgroundtransaction

Create Spore DOB

Mint an on-chain digital object (DOB) using the Spore protocol. Demonstrates cluster creation and content upload.

playgroundtransactionspore

Transfer Spore DOB

Transfer an existing Spore DOB to another address.

playgroundtransactionspore

Backend Transfer (Node.js)

Send CKB from a Node.js backend using @ckb-ccc/shell with a private key signer — no browser required.

backendtransaction

DOB Cookbook — Colorful Loot

Create a colorful loot DOB using the Spore DOB Cookbook recipes. Demonstrates advanced DOB patterns.

playgroundspore

Issue xUDT — Single-Use Lock

Issue a new xUDT token using the Single-Use Lock pattern. The lock is consumed after issuance, preventing re-minting.

apptransactionudt

Issue xUDT — Type ID

Issue an xUDT token controlled by a Type ID cell, allowing future minting by the same controller.

apptransactionudt

Create Spore Cluster

Create a Spore Cluster — a logical grouping for on-chain digital objects (DOBs).

apptransactionspore

Mint Spore

Mint a Spore DOB under a cluster through the CCC App UI.

apptransactionspore

Transfer / Melt Spore

Transfer a Spore DOB to another address, or melt (destroy) it to reclaim CKB capacity.

apptransactionspore

Transfer Spore Cluster

Transfer ownership of a Spore Cluster to another address.

apptransactionspore

Time-Locked Transfer

Send CKB with a time lock — the recipient cannot spend the output until a specified block number or timestamp.

apptransaction

SSRI Contract Call

Interact with on-chain smart contracts through the SSRI (Script-Sourced Rich Information) protocol.

apptransaction

Transfer CKB (Lumos)

Transfer native CKB using the legacy Lumos SDK with CCC's compatibility patches.

apptransaction

CKB Hash Calculator

Calculate the CKB hash (Blake2b-256) of any message. A quick utility for developers.

apptool

Mnemonic & Keypair Generator

Generate BIP-39 mnemonic words and derived keypairs. Optionally encrypt to a keystore file.

apptool

Keystore Decryptor

Decrypt a CKB keystore file to recover the private key.

apptool

Dep Group Manager

View and manage CKB dependency groups (DepGroup) used in transaction cell deps.

apptool

Contribute your examples

We welcome community contributions! Whether it's a handy utility script, an interesting on-chain data analysis, or an integration example for a new protocol — it can be included here to help more people get started with CKB development.

Via GitHub Pull Request

To have your example included in the official repository:

Fork and clone the repo

Go to ckb-devrel/ccc, click Fork, then clone locally:

git clone https://github.com/<your-username>/ccc.git
cd ccc

Write your script

Create a new .ts file in packages/examples/src/, using camelCase naming (e.g. myNewExample.ts). Your script should:

  • Import the SDK from @ckb-ccc/ccc
  • Import render, signer, etc. from @ckb-ccc/playground
  • Call await render(tx) at key steps to enable visualization in the Playground

See transfer.ts for a reference.

Test locally

Paste your script into the Playground and verify it runs correctly on Testnet.

Open a Pull Request

Push to your fork and open a PR against the master branch of ckb-devrel/ccc. Briefly describe the example's purpose and use case in the PR description.

Quick share (no PR needed)

The Playground can load code from any publicly accessible URL via the ?src= parameter — your GitHub repo, a Gist, or any raw file URL:

https://live.ckbccc.com/?src=<your-raw-file-url>

Share the generated link with colleagues or the community — they can open it and run your code immediately.

The built-in Share button stores code on Nostr relay nodes. Nostr share links are great for quick collaboration, but relay nodes do not guarantee permanent data retention — links may expire over time. For long-lived, stable share links, host your script in a GitHub repository and load it via ?src=https://raw.githubusercontent.com/... — the link will remain valid as long as the repository and file exist.

Last updated on

On this page