> 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/rome-academy/07-open-to-solana-wallets.md).

# EVM アプリを Solana ウォレットに開放する

EVM キーなしで Solana ウォレットからコントラクトを使えるようにします。合成アドレス、ERC-20 の値、2つの署名、そして原子的な予算を扱います。

あなたのコントラクトはすでに MetaMask で動作しています。ここでは、Solana ウォレットがすでに持っている鍵でそれを呼び出せるようにするため、ユーザーは EVM アカウントを作成しません。ユーザーは同じコントラクトを、同じアドレスで、同じ状態に対して呼び出します。

## 学べること

* Solana ウォレットが通常の `msg.sender` になる方法。
* このコースが値を ERC-20 のデポジットとして受け取る理由と、何を `msg.value` Solana ユーザーに求めるのか。
* Solana ユーザーが各呼び出しで署名するものと、トランザクションの送信先。
* 1 つの Solana トランザクションに収まるものと、収まらない呼び出しに何が起こるか。
* どの `依存関係` を SDK が必要とし、それぞれがどこから来るか。

## 始める前に

* 完了 [6. 両側のトークン](https://docs.rome.builders/ja/rome-academy/06-tokens-on-both-sides.md)。このレッスンでは、wrapper とは何か、そしてユーザーがなぜそれを一度だけ承認するのかを知っていることを前提とします。
* 持っている `HelloRome` Hadrian にデプロイされた [3. Hadrian上での最初のコントラクト](https://docs.rome.builders/ja/rome-academy/03-first-contract-on-hadrian.md).
* 以下のように TypeScript SDK をインストールする [Rome SDK](https://docs.rome.builders/ja/zhi-pin/rome-sdk.md#typescript-sdk-rome-protocol-sdk).
* Solana v1 トランザクションに署名できる Solana ウォレットと、少量の devnet SOL および devnet USDC を用意してください。Faucet は次に一覧があります: [ファウセット](https://docs.rome.builders/ja/rissu/faucets.md)。v1 トランザクションのサポートはウォレットによって異なるため、まずはお使いのものをテストしてください。 [デュアルレーンアプリを作る](https://docs.rome.builders/ja/gaido/dual-lane-app.md) これまでに確認したウォレットの名前を示します。

## レッスン

### ステップ 1。synthetic アドレスを理解する

Solana ウォレットには EVM アドレスがないため、Rome はその公開鍵からそれを導出します。その結果がウォレットの synthetic アドレスです。それは `msg.sender` コントラクトから見えるアドレスであり、他のアカウントと同様に独自の nonce とストレージを持ちます。同じウォレットは常に同じアドレスに対応します。

```javascript
import { syntheticAddress } from "@rome-protocol/sdk";
const from = syntheticAddress(solanaPubkey); // an ordinary 20-byte address
```

このコースの流れでは、synthetic は待機中にトークンを保持しません。トークンはユーザーの Solana ウォレットから始まります。資金移動の段階で、デポジットの前にそれらを synthetic のトークンアカウントへ移し、その時点で初めて wrapper の `balanceOf(synthetic)` がそれらを表示します。回収の段階で、withdraw の後にそれらをウォレットへ戻します。完全なモデルは次で読めます。 [Solana から EVM を呼び出す](https://docs.rome.builders/ja/gaido/call-evm-from-solana.md#synthetic-addresses).

### ステップ 2。コントラクトを Solana 対応にする

ほとんどのコントラクトは変更不要です。あなたのものがそうかどうかは、次の 3 つのルールで決まります:

* 価値は ERC-20 として受け取る。次で引き出す `transferFrom` の後に `approve`、そして次で返す `transfer`.
* 各トークンについて正規の wrapper を指してください。独自にデプロイしないでください。
* 各 Solana-lane の呼び出しを 1 つの Solana トランザクション内に収めてください。

最初のルールが厄介です。このエントリポイントは MetaMask ユーザーには動作します。ですが、fund-and-sweep モデルの Solana ユーザーでは失敗します。なぜなら、synthetic に次で資金を供給しない限り、native 残高を持たないからです。 `fundSyntheticGas`:

```solidity
function deposit() external payable { balanceOf[msg.sender] += msg.value; }
```

これは両方で動作します。どちらの lane も次を資金供給できるからです。 `transferFrom`:

```solidity
function deposit(uint256 amount) external {
    require(token.transferFrom(msg.sender, address(this), amount));
    balanceOf[msg.sender] += amount;
}
```

wrapper アドレスは次にあります。 [Contract Addresses](https://docs.rome.builders/ja/rifarensu/contract-addresses.md)。Solana 対応コントラクトのチェック項目は次にあります。 [Solidity コントラクトを Solana ユーザーに開放する](https://docs.rome.builders/pages/b60ca93ce19de4b87c9071515ef1bdbf151df2a6#id-2.-what-makes-a-contract-solana-ready).

### ステップ 3。ウォレットが何に署名するかを知る

SDK 呼び出しは `submitRomeTxV1`。各呼び出しごとに、proxy は 1 つの Solana v1 トランザクションを組み立てます。ウォレットは同じ鍵で 2 回署名します。まず、EVM トランザクションハッシュを示す可読な認可メッセージに署名します。次に、そのトランザクション自体に署名します。

アプリは署名済みトランザクションを Rome proxy ではなく Solana RPC に送ります。チェーンは Ed25519 プログラムを通じて認可を検証し、あなたの呼び出しを synthetic アドレスとして実行します。ユーザーが EVM 鍵を保持することはありません。

ウォレットがトランザクションに署名する前に、SDK はそれがユーザーが認可した呼び出しと完全に一致することを確認します。それ以外は拒否されます。詳細は次にあります。 [Solidity コントラクトを Solana ユーザーに開放する](https://docs.rome.builders/pages/b60ca93ce19de4b87c9071515ef1bdbf151df2a6#id-3.-let-a-solana-wallet-call-it).

### ステップ 4。lane を接続する

SDK には 5 つの値が必要です。proxy URL、chain ID、Rome program ID、Solana RPC 接続、そして signer です。4 つはチェーンを表し、1 つはウォレットから来ます。

```javascript
const deps = { connection, proxyUrl, chainId, programId, signer };
const res = await submitRomeTxV1(deps, { to: helloRome, data }); // helloRome: your lesson 3 contract; data: the ABI-encoded greet() call
```

Hadrian では、4 つの chain 値を registry から読み取ってください。対応表は次の `依存関係` ステップ 3 でリンクされたガイドの表にあり、値は次にあります。 [Hadrian](https://docs.rome.builders/ja/nettowku/hadrian.md)。レッスン 11 では、Rubicon 向けの同じ接続方法を扱います。

新しいユーザーが最初に value を動かす呼び出しを行う前に、1 回だけ行う手順が 2 つあります。synthetic を次で用意し、 `buildCreatePdaCall`、そして wrapper を付与してください。条件は次です。 `isEnabled` が false の場合。 `submitRomeTxV1` はあなたの代わりに provision しません。レッスン 9 では両方を順番に実行します。

### ステップ 5。1 つのトランザクション内に収める

Solana-lane の呼び出しは 1 つの Solana トランザクションに収まる必要があります。目安は 140 万 compute units、64 アカウント、4 KB です。計測には次を使います。 `computeUnitsConsumed` Solana の receipt からであり、EVM の `gasUsed`。トランザクションは次を指定して要求してください。 `maxSupportedTransactionVersion: 1`。これがないと RPC は要求を拒否します。

呼び出しが収まらない場合、composer はそれを拒否し、SDK は同じ認可署名のまま proxy に渡して中継させます。ユーザーにはそれでも 1 つのプロンプトしか表示されません。結果には `route: "relay"`。中継された呼び出しは synthetic の native gas を消費するため、まず次で補充してください。 `fundSyntheticGas`。revert する中継呼び出しは throw しません。次を確認してください。 `receipt.status`。ルールは次にあります。 [中継呼び出しと長い呼び出し](https://docs.rome.builders/ja/gaido/call-evm-from-solana.md#relayed-calls-and-long-calls)。1 つの表にまとめた制限: [制約](https://docs.rome.builders/ja/ji-ben-gai-nian/constraints.md).

## 確認しよう

これらに答えてから、解答を開いてください。

1. なぜ `payable` なデポジットは Solana ユーザーで失敗するのか?
2. ウォレットは 1 回の呼び出しごとに何回署名し、それぞれは何をカバーしますか?
3. 署名済みトランザクションはどこへ送られますか?
4. 呼び出しに複数のトランザクションが必要です。ユーザーには何が見え、誰が支払いますか?

<details>

<summary>解答</summary>

1. ユーザーの資金はウォレット内の SPL トークンであり、Rome では wrapper として表示されます。synthetic は、資金を供給しない限り fund-and-sweep モデルでは native 残高を持たないため、 `msg.value` 送るものはありません。
2. 2 回です。1 回目は EVM トランザクションハッシュを含む可読な認可メッセージをカバーし、2 回目は Solana トランザクションをカバーします。
3. アプリによって送信された Solana RPC です。proxy はトランザクションを組み立てますが、relay された呼び出しを除いて受け取りません。
4. 認可プロンプトは 1 つです。proxy が呼び出しを中継し、synthetic の native gas 残高がそれを支払います。

</details>

## 次へ

[8. SolanaプログラムをEVMユーザーに開放する](https://docs.rome.builders/ja/rome-academy/08-open-your-solana-program-to-evm-users.md)


---

# 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/rome-academy/07-open-to-solana-wallets.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.
