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.
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.
Transfer CKB
Send a specified amount of native CKB to another address. Demonstrates the declare → fill → fee → send pattern.
Transfer All CKB
Sweep an entire wallet's CKB balance into a single output. Uses completeInputsAll and completeFeeChangeToOutput.
Transfer UDT Token
Transfer xUDT fungible tokens between addresses. Demonstrates UDT cell construction and input completion.
Sign & Verify Message
Sign an arbitrary message with the connected wallet and verify the signature on-chain. Works across all wallet types.
Custom UI — Specified Wallet
Connect a specific wallet type in your own custom UI without using the built-in connector modal.
Custom UI — All Wallets with Controller
Enumerate and connect all supported wallets using SignersController for a fully custom wallet UI.
Query Balance
Query the CKB balance of any address on testnet or mainnet. A simple read-only script.
Query Cells
Iterate over live cells owned by an address. Demonstrates the cell collector pattern.
Query Transactions
Fetch transaction history for an address. Shows how to use the transaction iterator.
NervosDAO Deposit & Withdraw
Deposit CKB into NervosDAO and withdraw with interest. Covers the full DAO lifecycle.
Create Spore DOB
Mint an on-chain digital object (DOB) using the Spore protocol. Demonstrates cluster creation and content upload.
Transfer Spore DOB
Transfer an existing Spore DOB to another address.
Backend Transfer (Node.js)
Send CKB from a Node.js backend using @ckb-ccc/shell with a private key signer — no browser required.
DOB Cookbook — Colorful Loot
Create a colorful loot DOB using the Spore DOB Cookbook recipes. Demonstrates advanced DOB patterns.
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.
Issue xUDT — Type ID
Issue an xUDT token controlled by a Type ID cell, allowing future minting by the same controller.
Create Spore Cluster
Create a Spore Cluster — a logical grouping for on-chain digital objects (DOBs).
Mint Spore
Mint a Spore DOB under a cluster through the CCC App UI.
Transfer / Melt Spore
Transfer a Spore DOB to another address, or melt (destroy) it to reclaim CKB capacity.
Transfer Spore Cluster
Transfer ownership of a Spore Cluster to another address.
Time-Locked Transfer
Send CKB with a time lock — the recipient cannot spend the output until a specified block number or timestamp.
SSRI Contract Call
Interact with on-chain smart contracts through the SSRI (Script-Sourced Rich Information) protocol.
Transfer CKB (Lumos)
Transfer native CKB using the legacy Lumos SDK with CCC's compatibility patches.
CKB Hash Calculator
Calculate the CKB hash (Blake2b-256) of any message. A quick utility for developers.
Mnemonic & Keypair Generator
Generate BIP-39 mnemonic words and derived keypairs. Optionally encrypt to a keystore file.
Keystore Decryptor
Decrypt a CKB keystore file to recover the private key.
Dep Group Manager
View and manage CKB dependency groups (DepGroup) used in transaction cell deps.
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 cccWrite 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.
Node.js Backend
Use CCC for server-side CKB development, data analysis, and scripting.
CCC Package Guide
A complete overview of every NPM package in CCC. Choose the right package based on your runtime environment, framework, and feature requirements — covering the core SDK, wallet integrations, protocol extensions, and more.