CCC Playground
Learn to use the CCC Playground — an in-browser IDE for writing, running, and sharing CKB transaction scripts.
The CCC Playground is an in-browser IDE where you can write, execute, and visualize CKB transactions — no local setup required. It is the fastest way to learn CCC and experiment with CKB.
What you'll get
After this guide you'll be able to:
- Understand how the Playground works and how to use it
- Use the Playground for debugging and visualizing CKB transactions
- Write, run, and share CKB transaction scripts in the browser
- Build and send transactions using the CCC SDK
Interface overview
The Playground is split into two panels:
- Left panel — a Monaco (VS Code) editor with full TypeScript IntelliSense for CCC types
- Right panel — an output timeline that displays logs, errors, and interactive transaction visualizations
Drag the divider to resize the panels, or focus it and use the arrow keys. On narrow screens, use the Code / Output tabs. The top bar contains network and wallet controls; run controls stay below the editor.
Toolbar buttons
| Button | Description |
|---|---|
| Testnet / Mainnet | Toggle between CKB testnet and mainnet |
| Format | Auto-format your code with Prettier |
| Run | Execute the code and auto-step through render() breakpoints |
| Step | Execute in debug mode — pause at each render() and click Continue to advance |
| Share | Publish your code to Nostr relays and generate a shareable URL |
| Connect | Open the wallet connector to sign and send real transactions. Once connected, this button will display the CKB address of the connected wallet. |
| Load source | Load a raw HTTP(S) URL or a Nostr reference without running it |
| Examples / Save | Start from an editable example or download the editor contents |
| Clear on run | Clear the timeline before each run; disable to compare runs |
| Clear | Clear all console output |
| Docs / More | Links to documentation, GitHub, faucet, and CKBadger |
Repository examples
Examples starts with the CKB, xUDT, and Spore transfer builders, followed by
balance, live cell, transaction history, and DID queries. They load the current
packages/examples/src sources from the CCC repository’s master branch; there
are no separate Picker copies. Loading requires network access and does not run
code or change networks. Review the source before pressing Run. Cancelling
a load keeps the current editor and saved draft.
The transfer examples preview transactions to the selected wallet itself. They do not sign or broadcast. The CKB example needs enough spendable CKB. The xUDT example also needs a balance of the specific token in its source; a balance of a different xUDT is not sufficient. The Spore example reports an empty result if the wallet has no Spores. Results depend on the selected wallet and network, including when using the read-only Example wallet. The initial editor code is unchanged. Edit the DID identifier for the selected network; an absent DID is a valid empty result.
Available imports
Scripts run as JavaScript in the page, not a security sandbox. Only execute trusted code. The following modules are available:
import { ccc } from "@ckb-ccc/ccc"; // Core CCC SDK
import { render, signer, client } from "@ckb-ccc/playground"; // Playground helpers@ckb-ccc/playground exports
| Export | Type | Description |
|---|---|---|
signer | ccc.Signer | The connected wallet signer, or an explicitly selected read-only example signer |
client | ccc.Client | The active CKB client (testnet or mainnet) |
render(...args) | Promise<void> | Log values to the Console and pause execution (acts as a breakpoint in Step mode) |
You can also use console.log() and console.error() — they output to the Console panel.
Without a wallet, use client for chain reads or construct local values. Importing signer alone is harmless; actually accessing
signer state or calling its methods raises a clear choice in the Console:
Connect real wallet or Use example wallet. The example uses the original
Playground public address with no private key. It supports reading and building
transaction examples, but cannot sign or send. Available example inputs depend
on the selected network and address balance.
The top bar labels it Example wallet · read-only and offers a one-click disconnect. Historical output keeps its Example wallet label and original network after switching. Connecting your own wallet replaces the example; disconnecting it does not silently restore the example. After either choice, the Console adds a separate Wallet ready entry with Run current code. The original failed run stays an Error, including in the error count and filter. Only the new Wallet ready entry is informational; connecting does not rewrite the failure. Review the current editor contents before running; older connection entries remain historical. Selecting or connecting never automatically runs code, signs or sends.
After understanding the basic interface and available tools, let's explore the core capabilities of the Playground through practical examples.
Concurrent awaited render() checkpoints advance in creation order. Unawaited
checkpoints stop advancing once the top-level script ends; this does not cancel
arbitrary JavaScript. History-driven source changes wait until a run settles.
Example 1 — Transfer CKB
This is the default example that ships with the Playground. It demonstrates how to declare outputs → fill inputs → complete the fee without signing or sending.
Open the Playground and paste this code (or simply use the default):
import { ccc } from "@ckb-ccc/ccc";
import { render, signer } from "@ckb-ccc/playground";
console.log("Welcome to CCC Playground!");
// The receiver is the signer itself on mainnet
const receiver =
signer.client.addressPrefix === "ckb"
? await signer.getRecommendedAddress()
: "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqflz4emgssc6nqj4yv3nfv2sca7g9dzhscgmg28x";
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, 1000);
await render(tx);What happens when you click Run
- The code creates a transaction with one output of 100 CKB
render(tx)displays the transaction in the output timeline. In Run, execution continues automatically; only Step pauses at the checkpoint. At this point you'll see the output Cell but no inputs yetcompleteInputsByCapacityfinds live cells to cover 100 CKB, thenrender(tx)shows the transaction again — now with inputscompleteFeeByadds a change output and adjusts for the fee, thenrender(tx)shows the final transaction
Click Step instead of Run to pause at each render() call. Click
Continue to advance to the next breakpoint. This is useful for studying
how CCC builds a transaction step by step.
Now that we've mastered the basic transfer flow, let's explore a more complex scenario — creating a Spore.
Example 2 — Create a Spore
This example shows how to create a Spore — a non-fungible token on CKB:
import { ccc } from "@ckb-ccc/ccc";
import { render, signer } from "@ckb-ccc/playground";
const { tx, id: sporeId } = await ccc.spore.createSpore({
signer,
data: {
contentType: "text/plain",
content: new TextEncoder().encode("Hello, Spore!"),
},
});
console.log("Spore ID:", sporeId);
await render(tx);
await tx.completeInputsByCapacity(signer);
await render(tx);
await tx.completeFeeBy(signer);
await render(tx);About sending transactions: The above examples are for demonstration purposes only — they build the transaction to its final state without actually sending it. To broadcast the transaction to the chain, call signer.sendTransaction(tx) at the end:
// Sign and broadcast the transaction, returning the transaction hash
const txHash = await signer.sendTransaction(tx);
console.log("Transaction sent:", txHash);Make sure you have connected a wallet and that the address has sufficient CKB balance.
Playground's capabilities go far beyond building transactions. All methods provided by the CCC SDK can be run directly here, meaning you can write arbitrary scripts to perform various on-chain operations — for example, batch asset management, tracking large on-chain transactions, analyzing cell state distributions, and more. Below is a simple data query example.
Example 3 — Query on-chain data
You can use the Playground to explore on-chain data without building any transaction:
import { ccc } from "@ckb-ccc/ccc";
import { signer, client } from "@ckb-ccc/playground";
// Get the current tip block number
const tip = await client.getTip();
console.log("Current tip block:", tip.toString());
// Get the signer's address
const address = await signer.getRecommendedAddress();
console.log("Signer address:", address);
// Get the signer's balance
const balance = await signer.getBalance();
console.log("Balance:", ccc.fixedPointToString(balance), "CKB");Understanding the Cell visualization
When render() receives a ccc.Transaction, the output timeline captures a snapshot. Later mutations to that transaction do not rewrite an earlier checkpoint.
Each snapshot shows input capacity, output capacity and the capacity difference (fee when the transaction is complete). Unresolved inputs display Unknown, and checkpoints without sufficient inputs do not claim a zero fee. DAO extra capacity is listed separately.
The Inputs → Outputs flow uses compact cell cards. Each card shows its capacity, data size and a nested Bagua fingerprint: Lock outside and Type inside. Every trigram stays within the card. The center stays open: the fingerprint identifies scripts rather than suggesting a capacity gauge. Exact occupied/free values and a capacity breakdown appear in the inspector; unknown or invalid capacity is never shown as an accurate ratio. The pattern and color come from the script hash, so matching scripts have matching visual identities. On desktop, drag the arrow between the two sides to adjust their widths, or focus it and use the arrow keys (Home resets). On mobile, switch between Inputs and Outputs using the count tabs.
Select a cell to inspect its OutPoint, Lock and Type scripts, raw data, occupied capacity and free capacity in a full-width panel beneath the transaction flow. The selected cell remains identified by its input/output index. Close the panel to return focus to its card. Explorer links remain tied to the output's original network even after the workbench network changes. Expand Raw transaction to inspect cell dependencies, witnesses and the full serialized snapshot.
The timeline also accepts addresses, scripts, cells, bytes, errors, JSON-compatible values and custom React elements. Use Errors to focus on failures, disable Following output to inspect earlier entries without automatic scrolling, and turn off Clear on run to compare runs.
Sharing code
Click Share to publish your code to a set of Nostr relays. The Playground generates a nevent identifier, verifies it can retrieve the published code, and offers a copyable URL like:
https://live.ckbccc.com/?src=nostr:nevent1...Anyone who opens this URL will see your exact code loaded in the editor. Code is stored on decentralized Nostr relays — no centralized server involved.
You can also load code from any URL by passing a src query parameter:
https://live.ckbccc.com/?src=https://raw.githubusercontent.com/sporeprotocol/dob-cookbook/refs/heads/main/examples/dob0/1.colorful-loot.tsTips
- Use
render()liberally — it's your primary debugging tool. Pass a transaction at each stage to see how CCC mutates it. - Step mode is your friend — click Step to pause at each
render(), inspect the state, then click Continue. Great for understanding the transaction lifecycle. - Local drafts persist — the local draft is saved automatically and restored when you return. Imported sources and example scripts do not overwrite that draft. Download them with Save, or use Load source → Restore local draft to return to your saved work.
- Get testnet CKB — click More → Testnet faucet to fund your testnet address, or visit faucet.nervos.org directly.
- Full IntelliSense — the editor provides autocomplete and type-checking for all CCC types, plus
@noble/curves,@noble/hashes, and@nervina-labs/dob-render. - Share to collaborate — after writing a script, click Share to generate a link that others can open to reproduce your code environment.
Important Notes
Before running any script, make sure the network environment shown in the top bar (Testnet or Mainnet) is correct. Operations on mainnet assets are irreversible.
- Testnet first, then Mainnet — any script should be run and confirmed to behave as expected on the testnet before switching to the mainnet. Never operate on mainnet assets directly.
- Check connection status — make sure the correct wallet and network are connected in the top bar before sending transactions.
- Minimum CKB capacity — each Cell must have at least 61 CKB to cover on-chain storage fees. If the output capacity is set too low, the transaction will be rejected by the node.
- Transactions are irreversible — once a transaction is confirmed on-chain, it cannot be undone. When operating on mainnet assets, it is recommended to carefully review the inputs and outputs of the transaction using
render()first. - Browser refresh — the local draft is saved in localStorage. Imported sources are reloaded from
?src=on refresh; download your changes before leaving. Example edits are not automatically saved over the local draft. - Execution timeout — scripts in the Playground run in the browser's main thread. If you write long loops or make many RPC calls, it may cause the page to freeze. It is recommended to execute in steps.
Next steps
- Compose Transactions — the full guide to building and sending transactions.
- UDT Tokens — issue and transfer fungible tokens.
- Spore Protocol — create on-chain digital objects.
- Connect Wallets — integrate wallet connections into your own app.
Checkpoints, drafts and sharing
render() always creates an awaited checkpoint, even if the browser stack cannot
be mapped to a source line; that checkpoint has no editor highlight. Step stays
on the Code pane so Continue remains reachable, while Run opens Output.
Remote loading keeps the current editor text until replacement succeeds, and a
failed browser draft write is labelled unsaved with a prompt to download using Save.
When a relay acknowledges a share but read-back fails, Retry verification checks
the acknowledged snapshot without publishing it again. If the code has changed,
choose the explicit new-share action to publish the current code instead.
Last updated on