> 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固有の挙動を示します。

## サポートされているメソッド

**コア（stateと実行）:** `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 サブスクリプション](https://docs.rome.builders/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` （常に `を呼び出し、返り値が`), `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` サブスクリプションは受け付けられるが、発火はしません。

## Rome拡張メソッド

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

| メソッド                              | 目的                                                                                                                                       |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `rome_emulateTx`                  | トランザクションをオフチェーンでエミュレートする（Solanaの実行結果を返す）                                                                                                 |
| `rome_emulateTxWithPayer`         | 特定のpayerに対してエミュレートする                                                                                                                     |
| `rome_emulateCallAccounts`        | エミュレートして、呼び出しが触れるSolanaアカウントを返す                                                                                                          |
| `rome_emulateRegRollup`           | rollup登録をエミュレートする                                                                                                                        |
| `rome_getResources`               | プロキシのリソースプール状態（payer、holder）を報告する                                                                                                        |
| `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ボディから、1つのSolana v1トランザクションを組み立てます。ウォレットが署名し、アプリがブロードキャストします。呼び出しを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` 上限は、書き込みでアカウントを作成するたびに失敗します。たとえば、これまで使われたことのないアドレスへの送金などです。
* **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`を指定してください。レシートベースのイベント検証（例: トランザクションを待ってそのログを読む）は影響を受けません。

### 手数料

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