> 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/can-kao-wen-dang/json-rpc.md).

# JSON-RPC 支持

Rome 的 EVM 端点采用标准的 Ethereum JSON-RPC。Foundry、Hardhat、ethers、viem 和 MetaMask 在 Rome 上的工作方式与在任何 EVM 链上一样。本页列出了受支持的内容，以及少数值得了解的 Rome 特定行为。

## 受支持的方法

**核心（状态与执行）：** `eth_chainId`, `eth_blockNumber`, `eth_getBalance`, `eth_getCode`, `eth_getStorageAt`, `eth_getTransactionCount`, `eth_call`, `eth_estimateGas`, `eth_gasPrice`, `eth_maxPriorityFeePerGas`, `eth_feeHistory`.

**区块与交易：** `eth_getBlockByNumber`, `eth_getBlockByHash`, `eth_getBlockReceipts`, `eth_getTransactionByHash`, `eth_getTransactionReceipt`, `eth_sendRawTransaction`，以及按索引/数量获取的变体。

**日志与过滤器：** `eth_getLogs`, `eth_newFilter`, `eth_newBlockFilter`, `eth_getFilterChanges`, `eth_getFilterLogs`, `eth_uninstallFilter`.

**WebSocket 订阅：** `eth_subscribe` / `eth_unsubscribe` (`newHeads`, `logs`)。参见 [WebSocket 订阅](/zh/kai-fa-zhe-zhi-nan/websocket-subscriptions.md).

**Net / web3：** `net_version`, `net_listening`, `net_peerCount`, `web3_clientVersion`.

### 不支持

`debug_traceTransaction` / `trace_*` （交易跟踪）， `eth_getProof`, `eth_createAccessList`, `eth_blobBaseFee` （不支持 blob 交易）， `txpool_*` （没有公共 mempool）。 `newPendingTransactions` 订阅会被接受，但不会发出任何事件。

## Rome 扩展方法

除标准 Ethereum RPC 外，代理还提供 `rome_*` 方法：

| 方法                             | 用途                           |
| ------------------------------ | ---------------------------- |
| `rome_emulateTx`               | 在链下模拟交易（返回 Solana 执行结果）      |
| `rome_emulateTxWithPayer`      | 针对特定 payer 进行模拟              |
| `rome_emulateCallAccounts`     | 模拟并返回调用所触及的 Solana 账户        |
| `rome_emulateRegRollup`        | 模拟一次 rollup 注册               |
| `rome_getResources`            | 报告代理资源池状态（payers、holders）    |
| `rome_mintId`                  | 解析 ERC-20 封装背后的 SPL mint     |
| `rome_buildInfo`               | 代理构建信息 + 链上程序信息              |
| `rome_isCompatible`            | 检查代理/程序兼容性                   |
| `rome_solanaTxForEvmTx`        | 根据 EVM 交易哈希获取 Solana 交易      |
| `rome_sendUnsignedTransaction` | 提交未签名交易（synthetic-sender 流程） |

## Rome 特定行为

### Gas 源自 Solana——请进行估算，不要硬编码

Rome 以 Solana compute units 计量执行，并以 EVM gas 形式呈现。实际影响：

* **始终让你的工具估算 gas。** `forge create`, `cast`，以及 Hardhat 的 call `eth_estimateGas` 在链上并自动获取正确的值。
* **不要硬编码 `21000` 用于原生转账。** 向尚不存在的地址转账的成本高于 21000（它会创建收款账户）。估算会处理这一点；硬编码的 `21000` gas 限制会在新收款方处失败。

### `forge script --broadcast` 需要 `--skip-simulation`

`forge script` 会从一个 **本地** 模拟中设置其广播 gas 上限，而这相对于 Rome 的 gas 模型会配置不足。添加 `--skip-simulation` 以便 Foundry 使用链上的 `eth_estimateGas` 而不是：

```bash
forge script script/Deploy.s.sol:Deploy \
  --rpc-url <RPC> --private-key $PRIVATE_KEY --broadcast --skip-simulation
```

`forge create`, `cast send`，而 Hardhat 不受影响——它们已经在链上估算。

### `eth_getLogs` 有范围上限（约 12,000 个区块）

与 Infura、Alchemy 以及其他生产级 RPC 一样， `eth_getLogs` 会拒绝过宽的区块范围（错误 `-32005`）。请限制你的查询：

```javascript
const latest = await provider.getBlockNumber();
const logs = await contract.queryFilter(filter, latest - 5000, latest);
```

一个 `queryFilter` 如果不指定范围，则会扫描全部历史并超出上限——请传入显式的 `fromBlock`/`toBlock`。基于收据的事件断言（例如等待交易并读取其日志）不受影响。

### 费用

`eth_gasPrice` 返回真实的、由预言机得出的价格；钱包（包括 MetaMask）会使用它并显示正确的费用。提交的费用字段会被宽松接受——无论是 legacy 还是 EIP-1559 交易，都可以使用标准工具的默认值正常提交。


---

# 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/can-kao-wen-dang/json-rpc.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.
