



浏览我们为你准备的可运行代码示例和交互式工具，使用下方标签筛选感兴趣的分类。

* 标记为 **playground** 的卡片可在 [CCC Playground](https://live.ckbccc.com/) 中直接打开运行。
* 标记为 **app** 的卡片指向 [CCC App](https://app.ckbccc.com/)——一个 CKB 小工具集，即使你不是开发者也可以通过图形界面完成常见操作。

<ExampleGrid
  lang="zh"
  items="[
{
  title: &#x22;转账 CKB&#x22;,
  description: &#x22;向指定地址发送一定数量的 CKB。演示声明 → 填充 → 手续费 → 发送交易的标准模式。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transfer.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;transaction&#x22;],
  source: &#x22;packages/examples/src/transfer.ts&#x22;,
},
{
  title: &#x22;转账全部 CKB&#x22;,
  description: &#x22;将钱包全部余额归集到单个输出。使用 completeInputsAll 和 completeFeeChangeToOutput。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transferAll.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;transaction&#x22;],
  source: &#x22;packages/examples/src/transferAll.ts&#x22;,
},
{
  title: &#x22;转账 UDT 代币&#x22;,
  description: &#x22;在地址间转移 xUDT 代币。演示 UDT Cell 的构造和输入补全。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transferUdt.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;transaction&#x22;, &#x22;udt&#x22;],
  source: &#x22;packages/examples/src/transferUdt.ts&#x22;,
},
{
  title: &#x22;签名与验证消息&#x22;,
  description: &#x22;使用连接的钱包对任意消息签名，并在链上验证签名。支持所有钱包类型。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/sign.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;wallet&#x22;],
  source: &#x22;packages/examples/src/sign.ts&#x22;,
},
{
  title: &#x22;自定义 UI——指定钱包&#x22;,
  description: &#x22;不使用内置连接弹窗，在自定义界面中连接指定类型的钱包。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/customUi.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;wallet&#x22;],
  source: &#x22;packages/examples/src/customUi.ts&#x22;,
},
{
  title: &#x22;自定义 UI——全部钱包（Controller）&#x22;,
  description: &#x22;使用 SignersController 枚举并连接所有支持的钱包，实现完全自定义的钱包连接界面。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/customUiWithController.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;wallet&#x22;],
  source: &#x22;packages/examples/src/customUiWithController.ts&#x22;,
},
{
  title: &#x22;查询余额&#x22;,
  description: &#x22;查询任意地址在测试网或主网上的 CKB 余额。简单的只读脚本示例。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/queryBalance.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;query&#x22;],
  source: &#x22;packages/examples/src/queryBalance.ts&#x22;,
},
{
  title: &#x22;查询 Cell&#x22;,
  description: &#x22;遍历指定地址拥有的活跃 Cell。演示 Cell 收集器模式。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/queryCells.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;query&#x22;],
  source: &#x22;packages/examples/src/queryCells.ts&#x22;,
},
{
  title: &#x22;查询交易历史&#x22;,
  description: &#x22;获取指定地址的交易记录。展示如何使用交易迭代器。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/queryTransactions.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;query&#x22;],
  source: &#x22;packages/examples/src/queryTransactions.ts&#x22;,
},
{
  title: &#x22;NervosDAO 存入与取出&#x22;,
  description: &#x22;将 CKB 存入 NervosDAO 并提取利息。涵盖完整的 DAO 生命周期。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/dao.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;transaction&#x22;],
  source: &#x22;packages/examples/src/dao.ts&#x22;,
},
{
  title: &#x22;创建 Spore DOB&#x22;,
  description: &#x22;使用 Spore 协议铸造链上数码物（DOB）。演示 Cluster 创建和内容上传。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/createSpore.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;transaction&#x22;, &#x22;spore&#x22;],
  source: &#x22;packages/examples/src/createSpore.ts&#x22;,
},
{
  title: &#x22;转移 Spore DOB&#x22;,
  description: &#x22;将已有的 Spore DOB 转移到另一个地址。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transferSpore.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;transaction&#x22;, &#x22;spore&#x22;],
  source: &#x22;packages/examples/src/transferSpore.ts&#x22;,
},
{
  title: &#x22;后端转账（Node.js）&#x22;,
  description: &#x22;在 Node.js 后端使用 @ckb-ccc/shell 配合私钥签名器发送 CKB，无需浏览器环境。&#x22;,
  href: &#x22;https://github.com/ckb-devrel/ccc/blob/master/packages/examples/src/backendTransfer.ts&#x22;,
  tags: [&#x22;backend&#x22;, &#x22;transaction&#x22;],
  source: &#x22;packages/examples/src/backendTransfer.ts&#x22;,
},
{
  title: &#x22;DOB Cookbook — Colorful Loot&#x22;,
  description: &#x22;使用 Spore DOB Cookbook 配方创建彩色 Loot DOB。演示高级 DOB 模式。&#x22;,
  href: &#x22;https://live.ckbccc.com/?src=https://raw.githubusercontent.com/sporeprotocol/dob-cookbook/refs/heads/main/examples/dob0/1.colorful-loot.ts&#x22;,
  tags: [&#x22;playground&#x22;, &#x22;spore&#x22;],
  source: &#x22;sporeprotocol/dob-cookbook&#x22;,
},
{
  title: &#x22;发行 xUDT——Single-Use Lock&#x22;,
  description: &#x22;使用 Single-Use Lock 模式发行 xUDT 代币。Lock 在发行后即被消耗，防止重复铸造。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/IssueXUdtSus&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;, &#x22;udt&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/IssueXUdtSus/page.tsx&#x22;,
},
{
  title: &#x22;发行 xUDT——Type ID&#x22;,
  description: &#x22;使用 Type ID Cell 控制的方式发行 xUDT 代币，允许同一控制者后续继续铸造。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/IssueXUdtTypeId&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;, &#x22;udt&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/IssueXUdtTypeId/page.tsx&#x22;,
},
{
  title: &#x22;创建 Spore Cluster&#x22;,
  description: &#x22;创建 Spore Cluster——链上数码物（DOB）的逻辑分组。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/CreateSporeCluster&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;, &#x22;spore&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/CreateSporeCluster/page.tsx&#x22;,
},
{
  title: &#x22;铸造 Spore&#x22;,
  description: &#x22;通过 CCC App 界面在指定 Cluster 下铸造 Spore DOB。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/MintSpore&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;, &#x22;spore&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/MintSpore/page.tsx&#x22;,
},
{
  title: &#x22;转移 / 销毁 Spore&#x22;,
  description: &#x22;将 Spore DOB 转移到其他地址，或销毁（Melt）以回收 CKB 容量。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/TransferSpore&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;, &#x22;spore&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/TransferSpore/page.tsx&#x22;,
},
{
  title: &#x22;转移 Spore Cluster&#x22;,
  description: &#x22;将 Spore Cluster 的所有权转移到其他地址。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/TransferSporeCluster&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;, &#x22;spore&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/TransferSporeCluster/page.tsx&#x22;,
},
{
  title: &#x22;时间锁转账&#x22;,
  description: &#x22;发送带时间锁的 CKB——接收方在指定区块高度或时间戳之前无法花费该输出。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/TimeLockedTransfer&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/TimeLockedTransfer/page.tsx&#x22;,
},
{
  title: &#x22;SSRI 合约调用&#x22;,
  description: &#x22;通过 SSRI（Script-Sourced Rich Information）协议与链上智能合约交互。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/SSRI&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/SSRI/page.tsx&#x22;,
},
{
  title: &#x22;转账 CKB（Lumos）&#x22;,
  description: &#x22;使用旧版 Lumos SDK 配合 CCC 兼容补丁进行 CKB 转账。&#x22;,
  href: &#x22;https://app.ckbccc.com/connected/TransferLumos&#x22;,
  tags: [&#x22;app&#x22;, &#x22;transaction&#x22;],
  source: &#x22;packages/demo/src/app/connected/(tools)/TransferLumos/page.tsx&#x22;,
},
{
  title: &#x22;CKB 哈希计算器&#x22;,
  description: &#x22;计算任意消息的 CKB 哈希值（Blake2b-256）。开发者常用的快捷工具。&#x22;,
  href: &#x22;https://app.ckbccc.com/utils/Hash&#x22;,
  tags: [&#x22;app&#x22;, &#x22;tool&#x22;],
  source: &#x22;packages/demo/src/app/utils/(tools)/Hash/page.tsx&#x22;,
},
{
  title: &#x22;助记词与密钥对生成器&#x22;,
  description: &#x22;生成 BIP-39 助记词及派生密钥对，可选加密导出为 Keystore 文件。&#x22;,
  href: &#x22;https://app.ckbccc.com/utils/Mnemonic&#x22;,
  tags: [&#x22;app&#x22;, &#x22;tool&#x22;],
  source: &#x22;packages/demo/src/app/utils/(tools)/Mnemonic/page.tsx&#x22;,
},
{
  title: &#x22;Keystore 解密器&#x22;,
  description: &#x22;解密 CKB Keystore 文件，恢复私钥。&#x22;,
  href: &#x22;https://app.ckbccc.com/utils/Keystore&#x22;,
  tags: [&#x22;app&#x22;, &#x22;tool&#x22;],
  source: &#x22;packages/demo/src/app/utils/(tools)/Keystore/page.tsx&#x22;,
},
{
  title: &#x22;Dep Group 管理器&#x22;,
  description: &#x22;查看和管理 CKB 交易中 Cell Deps 使用的依赖组（DepGroup）。&#x22;,
  href: &#x22;https://app.ckbccc.com/utils/DepGroup&#x22;,
  tags: [&#x22;app&#x22;, &#x22;tool&#x22;],
  source: &#x22;packages/demo/src/app/utils/(tools)/DepGroup/page.tsx&#x22;,
},
]"
/>

## 贡献你的示例 [#贡献你的示例]

我们欢迎社区开发者贡献自己的脚本！无论是一个实用的工具脚本、一段有趣的链上数据分析，还是一个新协议的集成示例，都可以收录到这里，帮助更多人快速上手 CKB 开发。

### 通过 GitHub 提交 [#通过-github-提交]

如果你希望将示例收录到官方仓库，请按照以下流程操作：

<Steps>
  <Step>
    **Fork 并克隆仓库**

    前往 [ckb-devrel/ccc](https://github.com/ckb-devrel/ccc) 点击 **Fork**，然后克隆到本地：

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

  <Step>
    **编写脚本**

    在 `packages/examples/src/` 目录下新建 `.ts` 文件，文件命名使用 camelCase，例如 `myNewExample.ts`。脚本需要：

    * 从 `@ckb-ccc/ccc` 导入 SDK
    * 从 `@ckb-ccc/playground` 导入 `render`、`signer` 等
    * 在关键步骤调用 `await render(tx)` 以便在 Playground 中可视化

    可参考 [`transfer.ts`](https://github.com/ckb-devrel/ccc/blob/master/packages/examples/src/transfer.ts) 的写法。
  </Step>

  <Step>
    **本地验证**

    将脚本粘贴到 [Playground](https://live.ckbccc.com/) 中运行，确认在 Testnet 上能正常执行。
  </Step>

  <Step>
    **提交 Pull Request**

    推送到你的 Fork 后，向 `ckb-devrel/ccc` 的 `master` 分支发起 PR。在 PR 描述中简要说明示例的用途和使用场景。
  </Step>
</Steps>

### 快速分享（无需 PR） [#快速分享无需-pr]

Playground 可以通过 `?src=` 参数加载**任意**公开可访问 URL 的代码——你的 GitHub 仓库、Gist、甚至任意原始文件 URL 都可以：

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

把生成的链接分享给同事或社区伙伴，对方打开即可直接运行你的代码。

<Callout type="info">
  Playground 内置的 **Share** 按钮会将代码存储到 Nostr 中继节点。Nostr 分享链接适合临时协作，但中继节点不保证数据永久留存，长时间后可能失效。如果你需要**长期稳定的分享链接**，建议将脚本托管到 GitHub 仓库，通过 `?src=https://raw.githubusercontent.com/...` 的方式加载——只要仓库和文件存在，链接就不会失效。
</Callout>


---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ckbccc.com/llms.txt
> Use this file to discover all available pages before exploring further.
