> For the complete documentation index, see [llms.txt](https://docs.rome.builders/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rome.builders/zh/canton-zk-evm/build-with-canton.md).

# 使用 Canton 构建

在 Ostia 上，除了普通的 EVM 合约之外，你还可以面向哪些目标、可以使用哪些 Canton 组件进行构建，以及哪些内容你今天就能在 DevNet 上独立完成，哪些由 Rome 运行。

Ostia 可运行普通 EVM 合约，也能连接 Canton。区块向 Canton 发出的请求称为 leg，并与该区块在同一笔 Canton 交易中提交。本页列出可交互的目标、每种目标背后的组成部分，以及目前在 DevNet 上哪些人可以使用它们。

每个组成部分的代码都位于开放仓库 [rome-protocol/canton-zk-evm](https://github.com/rome-protocol/canton-zk-evm)中，并采用 Apache License 2.0 许可。

| 目标                                                   | 说明                                 | 目前在 DevNet 上的情况                                                                                              |
| ---------------------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| [EVM 合约](#evm-contracts)                             | 使用你在以太坊上使用的工具部署 Solidity 应用。       | 你可以自行操作。                                                                                                     |
| [合约中的 Canton Coin](#canton-coin-in-your-contracts)   | 以 CC ERC-20 形式存在的 Canton Coin。     | 你可以自行操作，使用 [Bridge](https://docs.rome.builders/zh/canton-zk-evm/bridge.md).                                  |
| [在 Canton 上有对应孪生代币的 EVM 代币](#erc-20-twins-on-canton) | 带有孪生代币的 ERC-20，即 CIP-0056 代币。      | Rome 使用 WtROME（来自 tROME）和 TKA 运行该功能。钱包功能启用后，Bridge 会为 Canton 钱包转移这些代币。目前没有外部 Canton 钱包持有孪生代币。Rome 会注册新的孪生代币。 |
| [与 Canton 参与方进行支付](#payments-with-canton-parties)    | 一笔 ERC-20 支付，可在同一笔交易中执行 Canton 分配。 | Rome 使用测试参与方运行该功能；你无法在 DevNet 上自行运行。                                                                         |
| [Canton 交易场所](#a-canton-venue)                       | 一个将 Canton 代币兑换为 ERC-20 的 Daml 应用。 | Rome 运行该交易场所；目前已运行过一次。你无法在 DevNet 上运行交易场所。                                                                   |
| [你自己的网络](#your-own-network)                          | 在本地 Canton 网络上运行完整技术栈。             | 所有操作都由你自行完成。                                                                                                 |

## EVM 合约

使用 Foundry 或 Hardhat 部署，在区块浏览器中验证源代码，并通过 viem 或 ethers 连接。 [在 Ostia 上构建](https://docs.rome.builders/zh/canton-zk-evm/build-on-ostia.md) 提供操作步骤， [Ostia DevNet](https://docs.rome.builders/zh/canton-zk-evm/devnet.md#limits) 则说明限制。ERC-20、ERC-721、ERC-1155、ERC-3643 权限型代币、Uniswap V2，以及用于验证 TACEO Merces 证明的合约，都已在 Ostia 上运行。RedStone 价格消费者合约也已部署并通过验证。

## 合约中的 Canton Coin

Ostia 上的 Canton Coin 是一种普通 ERC-20，精度为 10 位小数，合约地址为 `0x4db3dea7c13116961fd3e438542ccfcca61a7547`。任何合约都可以持有并转移它。网关在 Canton 上的托管资产为其提供一比一的支持；区块浏览器会在 [`/twins`](https://ostia.devnet.romeprotocol.xyz/twins) 和 `GET /api/twins`.

你可以在 [Bridge](https://docs.rome.builders/zh/canton-zk-evm/bridge.md) 页面存入 Canton Coin 来获取 CC，也可以通过提现吗来取回 Canton Coin。该页面每天提供 20 枚测试用 Canton Coin。

## Canton 上的 ERC-20 孪生代币

你将 ERC-20 存入金库，Canton 参与方即可持有等量的孪生代币。该孪生代币是 CIP-0056 代币，其 instrument id 为 `erc20:<token address>`。赎回时会销毁孪生代币，并将 ERC-20 返还到 Ostia 地址。

**目前哪些人持有孪生代币。** 孪生代币遵循 CIP-0056，但这并不意味着它们会显示在每个 Canton 钱包中。只有当托管该代币的所有验证者都已审核通过 `ostia-twin` 0.1.0 和 0.2.0 后，参与方才能持有孪生代币；接收锁定资产的参与方还必须一次性签署 `TwinAcceptance`。目前只有 Rome 运行的参与方满足这些条件。尚无外部 Canton 钱包持有或发送孪生代币。

**连接你自己的 Canton 钱包：功能已构建，但尚未启用。** Bridge 页面连接的是你已有的 Canton 钱包。通过钱包签名创建的 Bridge 账户已于 2026-11-17 停用。钱包连接功能按钱包逐一启用，目前没有确定日期。启用取决于三项由钱包开发者和验证者决定的事项：钱包允许第三方 Daml 软件包之前，开发者会先审核该软件包；他们的一些规则会拦截以 `canton-` 开头的软件包名称（我们的链上软件包名为 `canton-zk-evm`）；此外，托管钱包各方的验证者必须持有 Ostia 的软件包。在这些条件满足之前，外部 Canton 钱包无法在 Bridge 上执行任何操作。在 DevNet 上，两个 twin 是 TKA 和 WtROME，金库地址为 `0x69f13a94f986021f1a7650eb611bf9b717aa495a`.

Twin 注册服务的响应地址为 `https://ostia.devnet.romeprotocol.xyz/twin-registry` （例如 `GET /twin-registry/healthz`）。该服务不持有任何密钥。

| 调用                                                                              | 返回内容                                                                |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `GET /healthz`                                                                  | Twin 和金库。                                                           |
| `GET /twin/v1/twins`                                                            | 每个 Twin 的代币、工具 ID 和金库。                                              |
| `GET /registry/...`                                                             | 代币标准的注册表 API：Twin 的元数据，以及转账和分配工厂。这样一来，验证者已审核 Twin 软件包的钱包就可以发送 Twin。 |
| `POST /twin/v1/lock-parts` 并附带 `{"receiver": <Canton party id>, "ref": <text>}` | 返回锁定 ID 和已注册的金库，供付款方在锁定操作中使用。                                       |

锁定的接收方只需签署一次 `TwinAcceptance` 。如果没有该签名，注册表会返回 409，构建器会在区块证明生成之前将该锁定排除在区块之外，因此 ERC-20 仍由付款方持有。连接到 Bridge 页面的 Canton 钱包会在选择加入时签署接受声明。付款方会自行检查锁定 ID、 `lock,<receiver>,<ref>`的 SHA-256 值，并从可信来源获取金库地址。

你可以验证该金库是否为经审核的构建版本。 `cast keccak $(cast code 0x69f13a94f986021f1a7650eb611bf9b717aa495a --rpc-url $RPC)` 返回 `0x2fbcf33083dd26a360690a0d8d24cd333997b3c7000d950aa5e564e01460d4da`，这也正是 `GET /api/twins` 报告的代码哈希。

目前，DevNet 上只有 Rome 会注册 Twin 和金库。若要申请为你自己的 ERC-20 创建 Twin，请在 [代码仓库](https://github.com/rome-protocol/canton-zk-evm/issues) 中提交 issue，或在 Rome 的 [Discord](https://discord.gg/vZ9rnCdNSB)中提出；Rome 会逐案决定。

## 与 Canton 参与方进行支付

EVM 付款方会调用网关的 `pay`。Canton 付款方和收款方已签署 `DvpTerms` ，其中指定了分配、付款 ID、EVM 代币、EVM 收款方和金额。在一笔 Canton 交易中，区块提交与分配执行同步完成，因此任何一方都不会单独成为最终结果。该功能已在 DevNet 的第 783 和 1471 号区块中运行。 [存款、取款和付款](https://docs.rome.builders/zh/canton-zk-evm/deposits-withdrawals-payments.md#tie-a-payment-to-one-allocation) 的规则见此处。

在 DevNet 上，Rome 的测试方会执行这些付款。Bridge 页面不会执行付款：它只执行四项跨桥操作。若要在自己的 Canton 各方之间执行与分配挂钩的付款，请运行你自己的网络（见下文）。

## Canton 交易场所

交易场所是一种 Daml 应用，用于在 Canton 卖方与 EVM 买方之间执行交易。组成部分如下：

* `otc-venue` 0.1.0 版本位于 [`apps/otc`](https://github.com/rome-protocol/canton-zk-evm/tree/main/apps/otc)，包含 `TradeOffer` 和 `Trade`。它仅依赖代币标准 CIP-0056，不指定区块链，因此任何交易场所都可以使用它。此 `Trade` 会在标准钱包中向卖方显示一项分配请求。
* 区块链的 Daml 软件包（0.4.0 及更高版本，固定使用 0.5.0）包含 `VenueTrade` 和 `FundedClaim`。交易场所和卖方会为每笔交易签署 `VenueTrade` 。
* 买方通过网关付款。卖方的分配操作与付款在同一笔 Canton 交易中执行，随后买方通过一个 `FundedClaim`.

在 2026-10-27 15:55 UTC，它在 DevNet 上运行：Canton 代币 TKB 被兑换为 ERC-20 代币 TKA。买方的付款记录在区块 16816 中，属于一次 Canton 更新；买方的领取记录在区块 16823 中。低于交易金额的付款未被纳入区块 16834，也没有转移任何资产。浏览器在 [`/swaps`](https://ostia.devnet.romeprotocol.xyz/swaps)列出兑换记录，而 `GET /api/swaps` 会返回这些记录。

在 DevNet 上，构建器以交易场所的 party 身份启动，因此 Rome 会添加一个交易场所。运行兑换的命令位于代码库的演示中，可用于本地网络或你自己的运行环境。卖方提议交易的步骤计划在主网上线前实现。

## 你自己的网络

[运行你自己的 Ostia](https://docs.rome.builders/zh/canton-zk-evm/run-it-locally.md) 会启动本地 Canton 网络和完整技术栈：区块链、证明器或其替代实现、网关和浏览器。在此环境中，除 Canton Coin 外，你可以自行运行上述所有组件；Canton Coin 需要 Canton Network 验证器。对此，请在你自己的验证器参与方上运行 Ostia（参见 [运行你自己的 Ostia](https://docs.rome.builders/zh/canton-zk-evm/run-it-locally.md#run-on-an-existing-participant)）。你将使用自己的 parties 和交易场所。

Daml 应用可以看到自己签署的各个 leg。任何人都可以通过浏览器上的 `GET /api/legs` 读取所有 leg。

## 接下来

* [用例](https://docs.rome.builders/zh/canton-zk-evm/use-cases.md)：这些组件目前能实现的功能。
* [Bridge](https://docs.rome.builders/zh/canton-zk-evm/bridge.md)：用于执行这四个步骤以及在 Canton 上发送资产的浏览器页面。
* [工作原理](https://docs.rome.builders/zh/canton-zk-evm/how-it-works.md)：一个区块从交易到 Canton 提交的过程。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rome.builders/zh/canton-zk-evm/build-with-canton.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
