> 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/ja/rifarensu/json-rpc.md).

# JSON-RPCサポート

Rome EVMエンドポイントでサポートされるEthereum JSON-RPCメソッドと、Rome固有の動作 — Foundry、Hardhat、ethers、viem、MetaMask向け。

Rome の EVM エンドポイントは標準の Ethereum JSON-RPC を話します。Foundry、Hardhat、ethers、viem、MetaMask は、ほかの EVM チェーンと同じように Rome に対して動作します。このページでは、サポートされているものと、知っておく価値のある 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`、block-by-index/count のバリアント。

**ログとフィルター:** `eth_getLogs`, `eth_newFilter`, `eth_newBlockFilter`, `eth_getFilterChanges`, `eth_getFilterLogs`, `eth_uninstallFilter`.

**WebSocket サブスクリプション:** `eth_subscribe` / `eth_unsubscribe` (`newHeads`, `logs`にあります。 [WebSocket サブスクリプション](/ja/gaido/websocket-subscriptions.md).

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

**小規模なイントロスペクション用メソッド:** `rpc_modules` （一覧します `debug`, `eth`, `net`, `rome`, `rpc`, `txpool`, `web3`), `eth_syncing` （常に `false`), `eth_accounts` （常に空のリストです）、 `eth_getUncleCountByBlockNumber`, `eth_getUncleCountByBlockHash`, `eth_getUncleByBlockNumberAndIndex` および `eth_getUncleByBlockHashAndIndex` （uncle はないため、カウントは `0x0` で、ルックアップは `null`), `eth_newPendingTransactionFilter` （受け付けられますが、公開 mempool がないためハッシュを返すことはありません）、そして `txpool_status`、これは常に `{"pending":"0x0","queued":"0x0"}` 公開 mempool がないためです。

**トレース:** `debug_traceRomeTransaction` トランザクションハッシュを受け取り、複数の呼び出しを 1 つのバッチにまとめたトランザクションについて、サブコールごとおよび CPI ごとの内訳を返します。通常のトランザクションは `null`を返しません。未知のハッシュ、またはまだインデックス化されていないハッシュも同様です。

### 非対応

`debug_traceTransaction` / `trace_*` （Ethereum 形式のトランザクション・トレース。これらは `-32601`), `eth_getProof`, `eth_createAccessList`, `eth_blobBaseFee` （blob トランザクションはありません）、そして `txpool_*` 以外のメソッドは `txpool_status` （公開 mempool はありません）。 `newPendingTransactions` サブスクリプションは受け付けられますが、一度も emit されません。

## Rome 拡張メソッド

標準の Ethereum RPC に加えて、プロキシは `rome_*` メソッドを公開します:

| メソッド                              | 目的                                                                                                                                            |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `rome_emulateTx`                  | オフチェーンでトランザクションをエミュレートします（Solana の実行結果を返します）                                                                                                  |
| `rome_emulateTxWithPayer`         | 特定の payer に対してエミュレートします                                                                                                                       |
| `rome_emulateCallAccounts`        | エミュレートし、呼び出しが触れる Solana アカウントを返します                                                                                                            |
| `rome_emulateRegRollup`           | ロールアップ登録をエミュレートします                                                                                                                            |
| `rome_getResources`               | プロキシのリソースプール状態（payers、holders）を報告します                                                                                                          |
| `rome_mintId`                     | ERC-20 ラッパーの背後にある SPL mint を解決します                                                                                                             |
| `rome_buildInfo`                  | プロキシのビルド情報 + オンチェーンプログラム情報                                                                                                                    |
| `rome_isCompatible`               | プロキシ/プログラムの互換性を確認します                                                                                                                          |
| `rome_solanaTxForEvmTx`           | EVM tx ハッシュに対応する Solana トランザクションを取得します                                                                                                        |
| `rome_sendUnsignedTransaction`    | 未署名トランザクションを送信します（synthetic-sender フロー）                                                                                                       |
| `rome_composeUnsignedAtomicV1`    | Solana ウォレットの Ed25519 署名で認可された未署名の EIP-1559 本文に対して、Solana v1 トランザクションを 1 つ作成します。ウォレットが署名し、アプリがブロードキャストします。呼び出しが 1 つの原子的トランザクションに収まらない場合は拒否します |
| `rome_composeUnsignedIterativeV1` | 同じですが、すべてのレグを返します（収まる場合は原子的、そうでなければ反復レグ）。ウォレットが各レグに署名し、次とともに送信します `rome_submitSignedV1Plan`                                                   |
| `rome_submitSignedV1Plan`         | 署名済みのプラン（最大 64 レグ）をブロードキャストします。プロキシは送信のみを行い、ウォレットが引き続き手数料支払者です                                                                                |
| `rome_relayUnsignedV1`            | ウォレットの署名は 1 回、プロキシの payer が各レグを駆動します。synthetic が Rome の gas を支払います（まず次で資金を補充してください `rome_composeExternalDepositV1`）。EVM tx ハッシュを返します          |
| `rome_composeExternalDepositV1`   | ウォレットのトークンから synthetic のネイティブ gas 残高に入金する、ウォレット署名済みのトランザクション 1 件                                                                              |

## Rome 固有の挙動

### Gas は Solana 由来です — ハードコードせず、見積もってください

Rome は実行を Solana の compute unit で計測し、それが EVM gas として表れます。書き込みのコストの大半は Solana アカウントの作成です。たとえば、これまで使われていない受取先、新しいトークンアカウント、デプロイ済みコントラクトなどです。これらのアカウントは見積もりに含まれます。実用上の結果:

* **使用してください `eth_estimateGas`、そして決してハードコードしないでください `21000`.** 標準ツール（`forge create`, `cast`、Hardhat、ethers、viem、MetaMask) はすでにそれを呼び出して使える値を取得します。Solana プログラムに触れる呼び出しでは、マージンを追加し（SDK の `submitRomeTx` は 1.3 倍を上乗せし）、見積もり自体が revert する場合は gas 上限を設定してください。ハードコードされた `21000` limit は、書き込みでアカウントが作成されるたびに失敗します。たとえば、これまで一度も使われたことのないアドレスへの送金などです。
* **Rome は実際に使用された gas を請求します。** 下の測定では、使用された gas が見積もりを上回ることはありませんでした。そのため、実際の作業より見積もりが高くても差額は請求されません。
* **ツールが追加するマージンはそのままにしてください。** 見積もりからトランザクションが着地するまでの間に状態が変わることがあり、Solana CPI を行う呼び出しの見積もりは低く出ることがあります。SDK の `submitRomeTx` は見積もりに 1.3 倍のマージンを上乗せします。

Hadrian で計測。当時の gas 価格は約 10.4 gwei でした:

| 書き込み                                  | `eth_estimateGas` | 使用 gas    |
| ------------------------------------- | ----------------- | --------- |
| 未使用アドレスへのネイティブ送金                      | 1,086,961         | 1,086,961 |
| 既存アドレスへのネイティブ送金                       | 21,000            | 10,001    |
| 未使用アドレスへの wUSDC 送金                    | 2,544,921         | 2,544,921 |
| gas を wUSDC にラップ（`withdraw_to_ata`)   | 21,000            | 10,001    |
| ラッパー付与（`approve_spl` Helper プリコンパイル上） | 21,000            | 10,001    |
| 10 バイトのコントラクトをデプロイ                    | 1,147,921         | 1,147,921 |

これらは 1 つのチェーン上での単発の測定値であり、上限ではありません。数値は、呼び出しがどのアカウントを作成しなければならないかに依存するため、コピーするのではなく、各書き込みごとに見積もってください。

### `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`を指定してください。receipt ベースのイベントアサーション（例: tx を待ってログを読む）は影響を受けません。

### 手数料

`eth_gasPrice` 実際のオラクル由来の価格を返します。ウォレット（MetaMask を含む）はそれを使用し、正しい手数料を表示します。送信された fee フィールドは寛容に受け入れられます — レガシーと 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 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/ja/rifarensu/json-rpc.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.
