> 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/he-xin-gai-nian/token-interop.md).

# 代币互操作

Rome 将一个 ERC-20 代币及其底层 SPL 代币表示为一个共享账户。本页说明代币如何在 EVM 和 Solana 之间运作。

## 共享状态模型

Rome 不会将代币锁定在一侧并在另一侧铸造包装副本。Rome 上的 ERC-20 代币是一个 **透明包装器** ，覆盖在 Solana 上的 SPL 代币账户之上——ERC-20 余额 *就是* SPL 余额。

<figure><img src="/files/136d5a08ff4cfdeff06cbc7c4d68585f934f4369" alt="An ERC-20 wrapper over the same SPL token account on Solana"><figcaption></figcaption></figure>

* 没有跨链延迟——ERC-20 余额就是 SPL 余额
* 没有流动性碎片化——双方的 DeFi 看到的是同一批代币
* 没有桥接风险——不存在可被利用的独立托管账户

> 下面的导入路径使用 `@rome-protocol/rome-solidity`。npm 发布尚待完成；目前你可以从公开的 [`rome-solidity`](https://github.com/rome-protocol/rome-solidity) 仓库（git 依赖或复制的接口）中获取这些内容。预编译接口位于 [`contracts/interface.sol`](https://github.com/rome-protocol/rome-solidity/blob/master/contracts/interface.sol).

## 包装合约

`SPL_ERC20` （以及其缓存轨道变体 `SPL_ERC20_cached`，工厂今天部署的就是它），为 SPL mint 提供完整的 ERC-20 接口：

* `balanceOf()` — 从 Solana 读取用户的 ATA 余额
* `transfer()` — 在 Solana 上转移代币
* `approve()` / `allowance()` — 使用 EVM 存储（SPL 不具备 EVM 风格的授权机制）
* `totalSupply()` — 读取 SPL mint 供应量

## 工厂

`ERC20SPLFactory` 会为任意 SPL mint 部署一个包装器：

```solidity
import {ERC20SPLFactory} from "@rome-protocol/rome-solidity/contracts/erc20spl/erc20spl_factory.sol";

// 部署一个包装器，从 Metaplex 元数据中加载名称/符号
address wrapper = factory.add_spl_token_with_metadata(splMint);

// 或手动指定名称/符号
address wrapper = factory.add_spl_token_no_metadata(splMint, "USD Coin", "USDC");
```

当前工厂地址：Hadrian `0x86149124d74ebb3aa41a19641b700e88202b6285`，Martius `0xd7aeeedca26cdd4d34eb7c21110af2e590a8c58a`。务必以 [registry](https://github.com/rome-protocol/rome-registry/tree/main/chains) 为准——它是已部署地址的唯一可信来源。

## 标准 mint

链上没有代币注册表合约。标准包装器以及 gas/bridge 代币由链下的 [`rome-protocol/registry`](https://github.com/rome-protocol/rome-registry)进行整理；通过 `add_spl_token_no_metadata` 创建的无需许可包装器，则通过链上的 `TokenCreated` 事件发现。这样可确保每种资产都映射到单一的标准 SPL mint，而不会造成流动性碎片化。

## 从 Solidity 进行 SPL 操作

对于由用户 PDA 签名的 SPL 原语，请使用 **HelperProgram** 预编译（`0xFF…09`）——ATA 创建、SPL 转账以及 gas↔lamports 转换：

```solidity
import {IHelperProgram} from "@rome-protocol/rome-solidity/contracts/interface.sol";

IHelperProgram helper = IHelperProgram(0xFF00000000000000000000000000000000000009);

helper.create_ata(user, mint);              // 为某个 mint 创建用户的 ATA
helper.transfer_spl(to, tokens, mint);      // 从调用者的 PDA 转移 SPL
```

`transfer_spl` 有多个重载版本（包括用于 `transferFrom` 流程的委托变体）；准确签名请参见 `interface.sol` 。在缓存轨道上，对应操作位于 `ISplCached` (`0xFF…05`）以及 `IAssociatedSplCached` (`0xFF…06`）。合约会始终使用同一条轨道。

## 存入和提取

* **进入 EVM** ——SPL 侧会将款项记入用户由 PDA 持有的 ATA；ERC-20 包装器会立即反映该余额。跨链入金通过桥上的用户签名授权以无需信任的方式完成结算。
* **转出到 Solana** ——调用 `Withdraw` 预编译（`0x42…16`): `withdraw_to_pda` / `withdraw_to_ata` 将代币从用户的 PDA 退回到 Solana。将 gas 包装为 SPL 的路径是 `withdraw_to_ata`.

## Gas 代币

每条链都有自己的 gas 代币——可以是任意 SPL 代币，其价格通过 Meteora DAMM 池（v1 或 v2，可配置）确定。公共链（Martius、Hadrian）使用 USDC。不存在统一的默认 gas 代币。

## 限制

* SPL 代币数量类型为 `uint64` （最大值 18,446,744,073,709,551,615）
* 授权使用的是 EVM 存储，而不是 Solana delegate
* 每个工厂的 ERC-20 包装器符号必须唯一

## 下一步

* [合约地址](/zh/can-kao-wen-dang/contract-addresses.md) — 预编译与各链地址
* [从 EVM 调用 Solana](/zh/kai-fa-zhe-zhi-nan/call-solana-from-evm.md) — 从 Solidity 进行 CPI 和 SPL 操作


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rome.builders/zh/he-xin-gai-nian/token-interop.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
