> 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/zhi-pin/rome-sdk.md).

# Rome SDK

EVMコントラクトからSolanaプログラムを呼び出すための型付きSolidityインターフェースと、Romeのオフチェーンサービスの基盤となるRust SDK。

Rome SDK は、EVMスマートコントラクトから Solana プログラムとやり取りするための型付き Solidity インターフェースを提供します。Rome 上でクロスランタイムアプリケーションを構築するための開発者向けツールキットです。

## SDK

Rome には、3つの対象者向けに SDK があります — アプリビルダー（TypeScript）、コントラクト開発者（Solidity）、そして Rome 上で独自のサービスを運用するチーム（Rust）です。

### TypeScript SDK (`@rome-protocol/sdk`)

**dapp およびフロントエンド開発者向け** — 多くのアプリビルダーが最初に使う SDK です。 [`@rome-protocol/sdk`](https://github.com/rome-protocol/rome-sdk-ts) Rome の書き込み経路をラップし、Web アプリが Rome トランザクションを正しく送信できるようにします: `submitRomeTx` （正しい書き込み経路と gas/fee 処理）、PDA / ATA の導出、CPI `invoke` / `invoke_signed` エンコーダー、precompile バインディング、そして `/bridge` サブパス。リポジトリ起点のインストール（npm publish は保留中）:

```bash
npm install github:rome-protocol/rome-sdk-ts#v0.4.0
```

```typescript
import { submitRomeTx } from '@rome-protocol/sdk';
// Rome EVM の任意の書き込みを、正しい書き込み経路で送信する（gas/fee のエンコードを処理）。
```

公開 [rome-dex](https://github.com/rome-protocol/rome-dex) app は SDK のヘルパーのうちごく一部しか使っていません（PDA とトークンアカウントの導出、CPI `invoke` エンコーダーと 1.3x の gas パッド）し、 [cardo](https://github.com/rome-protocol/cardo) それに依存していません。どちらも呼び出しは `submitRomeTx` または `submitRomeTxV1`を使わないので、SDK の書き込み経路ではなく、アプリが CPI precompile をどう呼び出すかを見るために読んでください。

**両方のレーン、1つの SDK。** `submitRomeTx` は EVM レーン（MetaMask）です。 **Solana レーン** — Solana ウォレットがあなたの EVM アプリを駆動する — `submitRomeTxV1` を対応させます: プロキシが呼び出し用に1つの Solana v1 トランザクションを組み立て、ウォレットは同じ鍵で2回署名します（読み取り可能な認可メッセージ、次にトランザクション）。そして Rome は、その呼び出しをユーザーの導出済みアイデンティティからの EVM トランザクションとして、EVM キーなしで実行します。1つのトランザクションに収まらない呼び出しは、同じ認可署名でプロキシによって中継され、 `fundSyntheticGas` は、中継された呼び出しが消費するネイティブ gas を補充します。revert した中継呼び出しは `receipt.status === "0x0"` として解決され、例外は投げられないので、それを確認してください。 [中継呼び出しと長い呼び出し](/ja/gaido/call-evm-from-solana.md#relayed-calls-and-long-calls) のセクションには gas のルールと制限があります。値の移動は `buildFundLeg` / `buildSweepLeg` ERC-20 ラッパーとして行われます（例: `wUSDC`）、ネイティブではありません `msg.value` — synthetic sender は静止時には何も保持しません — そして、最初の synthetic は一度だけ明示的に `buildCreatePdaCall`でプロビジョニングされます。以前の `submitRomeTxSolanaLane`、クライアント内で legacy Solana トランザクションを構築するものも、まだ SDK にあります。参照: [デュアルレーンアプリを構築する](/ja/gaido/dual-lane-app.md) および [SolanaからEVMを呼ぶ](/ja/gaido/call-evm-from-solana.md).

### Solidity SDK (`@rome-protocol/rome-solidity`)

**Solidity 開発者向け。** precompile インターフェース、ERC-20/SPL ラッパー、PDA 導出、CPI ユーティリティを提供します。npm publish は保留中で、現時点では公開 [`rome-solidity`](https://github.com/rome-protocol/rome-solidity) リポジトリ（git 依存関係またはコピーしたファイル）から利用します。

```solidity
import {ISystemProgram, ICrossProgramInvocation, IHelperProgram, IWithdraw}
    from "@rome-protocol/rome-solidity/contracts/interface.sol";
import {SPL_ERC20} from "@rome-protocol/rome-solidity/contracts/erc20spl/erc20spl.sol";
import {RomeEVMAccount} from "@rome-protocol/rome-solidity/contracts/rome_evm_account.sol";
```

### Rust SDK (`rome-sdk`)

**Rome 上で独自のサービスを運用するチーム向け。** トランザクション構成、Solana とのやり取り、gas 価格設定、ブロック索引を扱う Rust ワークスペースです。Proxy と Hercules はこれ上に構築されています。ソースは [`rome-protocol/rome-sdk`](https://github.com/rome-protocol/rome-sdk)にあります。Solana v1 トランザクション（4 KB、最大64アカウント）を送信します。

**これを構築しています。** このワークスペースはリポジトリ [`rome-sdk`](https://github.com/rome-protocol/rome-sdk), [`rome-evm`](https://github.com/rome-protocol/rome-evm) および [`mollusk`](https://github.com/rome-protocol/mollusk) が並んでクローンされていることを前提としています。これは、相対パスで他の2つに依存しているためです。そのため、別プロジェクトから使う推奨方法も、単純な git 依存関係ではなく path 依存関係になります。初回ビルドには Rust 1.85 以上とネットワークアクセスが必要です。 `rome-evm` にはデフォルトの network 機能がないため、これをコンパイルするビルドには次のいずれか1つが正確に必要です `ci`, `testnet` または `mainnet`; ローカル作業には `ci` を使ってください。例: `cargo test -p rome-sdk --features ci`。リポジトリの README に全手順と機能表があります。

**ライセンス。** Rust SDK は source-available であり、オープンソースではありません。全著作権所有で、個人的・非商用目的にのみ使用できます。商用利用には Rome Protocol の書面による許可が必要です。リポジトリの `LICENSE` に申請方法が書かれています。

## Solidity SDK: 含まれるもの

### Precompile インターフェース

インターフェースをその precompile アドレスにバインドします:

```solidity
ISystemProgram          constant System   = ISystemProgram(0xFF00000000000000000000000000000000000007);
ICrossProgramInvocation constant Cpi      = ICrossProgramInvocation(0xFF00000000000000000000000000000000000008);
IHelperProgram          constant Helper   = IHelperProgram(0xFF00000000000000000000000000000000000009);
IWithdraw               constant Withdraw = IWithdraw(0x4200000000000000000000000000000000000016);
// キャッシュ済みトラック: ISplCached 0xff…05, IAssociatedSplCached 0xff…06, ISystemCached 0xff…04, IWithdrawCached 0xff…0b
```

### SPL トークン操作

使用してください `IHelperProgram` (`0xff…09`) を使って、ユーザーの PDA 署名付き SPL プリミティブを扱います:

```solidity
// ミント用に呼び出し元の ATA を作成
Helper.create_ata(user, mint);

// 呼び出し元の PDA から SPL を送金
Helper.transfer_spl(to, tokens, mint);
```

キャッシュ済みトラックでは、同等の操作は `ISplCached` (`0xff…05`と `IAssociatedSplCached` (`0xff…06`にあります。 `interface.sol` すべてのオーバーロードについては参照してください。コントラクトは一貫して1つのトラックを使います。

### PDA の導出

```solidity
// ユーザーの Solana PDA を導出
bytes32 userPda = RomeEVMAccount.pda(msg.sender);

// salt を使って PDA を導出（ユーザーごとに複数の PDA を作成する場合）
bytes32 pda = RomeEVMAccount.pda_with_salt(msg.sender, salt);

// 任意の PDA を検索
(bytes32 pda, uint8 bump) = SystemProgram.find_program_address(programId, seeds);
```

### クロスプログラム呼び出し

```solidity
// 任意の Solana プログラムを呼び出し
ICrossProgramInvocation.AccountMeta[] memory accounts = new ICrossProgramInvocation.AccountMeta[](2);
accounts[0] = ICrossProgramInvocation.AccountMeta(signerPda, true, true);
accounts[1] = ICrossProgramInvocation.AccountMeta(targetAccount, false, true);

CpiProgram.invoke(programId, accounts, instructionData);

// PDA 署名付きで呼び出し
CpiProgram.invoke_signed(programId, accounts, data, seeds);

// アカウントデータを読み取る
(uint64 lamports, bytes32 owner, bool isSigner, bool isWritable, bool executable, bytes memory data)
    = CpiProgram.account_info(pubkey);
```

### SPL トークン上の ERC-20

```solidity
// 任意の SPL ミント用のラッパーをデプロイ
ERC20SPLFactory factory = ERC20SPLFactory(FACTORY_ADDRESS);
address wrapper = factory.add_spl_token_with_metadata(splMint);

// ラッパーを標準 ERC-20 として使う
SPL_ERC20 token = SPL_ERC20(wrapper);
token.transfer(recipient, amount);
uint256 balance = token.balanceOf(user);
```

### Borsh デシリアライゼーション

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

// Solana アカウントデータを解析（little-endian の Borsh 形式）
(uint64 value, uint256 newOffset) = Convert.read_u64le(data, offset);
(bytes32 pubkey, uint256 newOffset2) = Convert.read_bytes32(data, offset);
```

### Metaplex メタデータ

```solidity
import {MplTokenMetadataLib} from "@rome-protocol/rome-solidity/contracts/mpl_token_metadata/lib.sol";

// Metaplex からトークンメタデータを読み込む
MplTokenMetadataLib.Metadata memory meta = MplTokenMetadataLib.load_metadata(
    mintPubkey, mplProgramId, cpiAddress
);
string memory name = meta.name;
string memory symbol = meta.symbol;
```

## Rust SDK: アーキテクチャ

Rust SDK は Cargo ワークスペースです。主要なクレートは次のとおりです:

| クレート                | 目的                                                                                            |
| ------------------- | --------------------------------------------------------------------------------------------- |
| `rome-sdk`          | コア API: `Rome` struct、config、transaction types（RheaTx、RemusTx、RomulusTx）                      |
| `rome-evm-client`   | EVM rollup クライアント、TxBuilder、ResourceFactory、emulator 連携                                       |
| `rome-solana`       | Solana tower、RPC クライアント、トランザクションのバッチ処理と追跡                                                     |
| `rome-utils`        | RLP、hex、JSON-RPC、認証ユーティリティ                                                                    |
| `rome-obs`          | OpenTelemetry の可観測性（traces、metrics、logs）                                                      |
| `rome-meteora`      | gas 価格設定用の Meteora DAMM v1 および v2 のプールリーダー                                                    |
| `rome-meta-hook`    | Meta-Hook Router プログラム用クライアント: Token-2022 の transfer-hook 設定、追加アカウント解決、compute-budget 推定付きの送金 |
| `rome-jito-bundler` | 原子的なマルチトランザクション送信のための Jito バンドルビルダー                                                           |

### トランザクションタイプ

```rust
// 単一の rollup トランザクション
let rhea = RheaTx::new(signed_eth_tx);
let mut tx = rome.compose_rollup_tx(rhea).await?;
let sig = rome.send_and_confirm(&mut *tx).await?;

// クロス rollup の原子的トランザクション
let remus = RemusTx::new(vec![tx1, tx2]);
let mut tx = rome.compose_cross_rollup_tx(remus).await?;

// クロスチェーンの原子的トランザクション（EVM + Solana）
let romulus = RomulusTx::new(eth_txs, sol_ixs);
let mut tx = rome.compose_cross_chain_tx(romulus, signers).await?;
```

### リソースのプーリング

SDK は並列トランザクション送信のために Solana の keypair（payer）と holder アカウントインデックスをプールします:

```rust
let resource = resource_factory.get().await?;
let payer = resource.payer();       // Solana keypair
let holder = resource.holder();     // holder アカウントインデックス
// リソースは Drop 時に自動的にプールへ戻る
```

## SDK ロードマップ

### 構築済み・動作中

* SPL トークンラッパーと precompile インターフェース
* CPI 経由の Meteora DAMM v1 スワップ
* Oracle Gateway V1 + V2（Pyth Pull、Switchboard V3）
* System Program ヘルパー、Borsh デシリアライゼーション
* ERC20SPL Factory + ブリッジコントラクト

## 次は

* [Solidityをデプロイ](/ja/gaido/deploy-solidity.md) — SDK を使って最初のコントラクトをデプロイ
* [EVMからSolanaを呼ぶ](/ja/gaido/call-solana-from-evm.md) — CPI を使って Solana プログラムとやり取り
* [Contract Addresses](/ja/rifarensu/contract-addresses.md) — デプロイ済み SDK コントラクトのアドレス


---

# 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/zhi-pin/rome-sdk.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.
