> 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/kai-fa-zhe-zhi-nan/call-evm-from-solana.md).

# 从 Solana 调用 EVM

……的反向 [从 EVM 调用 Solana](/zh/kai-fa-zhe-zhi-nan/call-solana-from-evm.md)：Solana 钱包（例如 Phantom）可直接在 Rome 上调用任意 EVM 合约，且 **无需 Ethereum 密钥**。这就是 [Aerarium](/zh/rome-shang-de-ying-yong/apps.md) 和 [Rome DEX](/zh/rome-shang-de-ying-yong/apps.md) 让原生 Solana 用户与 EVM 用户共享相同合约的方式。

单次调用的方式是 SDK 的 `submitRomeTxSolanaLane`；本页将说明其作用。

## 合成地址

Solana 钱包的 EVM 身份是其 **合成地址** ——即 `keccak256` 对其 32 字节 Solana 公钥结果的最后 20 字节：

```
synthetic_evm_address = keccak256(solana_pubkey)[12:]
```

这就是 `msg.sender` 当钱包调用合约时所使用的身份，以及其 nonce 和存储所归属的稳定身份。该推导已在协议中固定，因此一个钱包始终映射到同一地址。

```javascript
import { syntheticAddress } from "@rome-protocol/sdk";
const from = syntheticAddress(solanaPubkey); // 0x… 20 bytes
```

## 合成地址是一个透传层——它在静态状态下不持有任何代币

Solana 原生用户可支配的余额存在于其 **Solana 钱包** 中（以 SPL 代币形式存在），在 EVM 侧一一对应地体现为该代币的 **ERC20SPL 包装器** （例如 `wUSDC`）。合成地址在静态状态下不持有任何资产，因此价值通过 *经由* 它流转——每一步都由 Solana 钱包签名：

1. **准备（一次性）。** 一个全新的合成地址的外部授权 PDA 在 `create_pda` 运行之前并不存在——而下面的转账由该 PDA 签名。 `submitRomeTxSolanaLane` 会在首次使用时自动为其准备（或调用 `provisionSynthetic` 以显式执行“激活”步骤；可通过 `isSyntheticProvisioned`).
2. **进行检查）** 资金转入环节（钱包 → 合成地址）。 `将代币从钱包的 ATA 转入合成地址的 ATA——由` ActivateAta `步骤构建，`通过 `buildFundLeg` 构建。此时`transfer` / `transferFrom`）—— **而不是** 原生 `msg.value`，因为它并不持有该值。
3. **调用（`DoTxUnsigned`).** 合成地址执行 EVM 交易——例如 `approve` 然后一个金库 `deposit` ，该操作通过 `transferFrom`.
4. **资金清扫环节（合成地址 → 钱包）。** 在 withdraw / borrow / claim 使代币进入合成地址后， `buildSweepLeg` 会将其转回用户自己的钱包 ATA（`HelperProgram.transfer_spl`），因此合成地址的净额归零。

## 调用是如何构建的

`submitRomeTxSolanaLane` 完成所有这些工作。其机制如下：

1. **构建一个未签名的 EIP-1559 交易** ，其 `from` = 合成地址——无需 secp256k1 签名。
2. **发现账户** ——调用 [`rome_emulateCallAccounts`](/zh/can-kao-wen-dang/json-rpc.md) ，传入调用的 `from`, `to`, `data`, **和 `value`** （当调用为可支付时）。传入 `value` 很重要：代理会模拟 *真实* 调用，因此任何依赖 value 的存储写入——例如一个新的映射槽——都会被分配并返回其对应的 Solana 账户。若省略它，则该账户会缺失，交易将因 *“instruction modified data of a read-only account.”*
3. **组装 Solana 交易：** 两条 **ComputeBudget** 指令（Rome 的 EVM 需要更高的 CU 上限，约 1.35M，以及较大的堆帧，约 250 KB——Solana 默认值会报错）+ **`DoTxUnsigned`** 指令（未签名的 RLP + 已发现的账户）+ 每条链的 **资金库钱包** （执行会向其支付一小笔费用；发现过程会省略它，因此 SDK 会追加它）。
4. **钱包签名并提交。** 该 **Solana 钱包对 Solana 交易进行签名（Ed25519），并将其发送到 Solana RPC——而不是发送到代理。** Solana 运行时会验证签名；在链上，程序会从该签名者派生出 `msg.sender` 。权限来源是 Solana 签名，而非 Ethereum 签名。（代理仅用于第 2 步中的模拟/发现。）

用户的 PDA（`["EXTERNAL_AUTHORITY", synthetic_address]`）拥有其代币账户，并代表其签署 SPL CPI，因此 Solana 用户可以完全通过 Phantom 提供、借入、交换和添加流动性。

## 参考实现

* **Aerarium** ——通过 `DoTxUnsigned`.
* **Rome DEX** 从 Phantom 驱动 Compound v3（供应 / 借贷）

——Solana 通道与 EVM 通道在同一池中进行交易和提供流动性。

## 下一步

* [从 EVM 调用 Solana](/zh/kai-fa-zhe-zhi-nan/call-solana-from-evm.md) ——通过 CPI 的另一方向
* [代币互操作](/zh/he-xin-gai-nian/token-interop.md) ——余额如何在 EVM 与 Solana 之间共享


---

# 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/kai-fa-zhe-zhi-nan/call-evm-from-solana.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.
