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

# 7. EVM 앱을 Solana 지갑에 개방하기

EVM 키 없이도 Solana 지갑에서 컨트랙트를 사용할 수 있게 만드세요. 합성 주소, ERC-20 값, 두 개의 서명, 원자적 예산을 다룹니다.

당신의 계약은 이미 MetaMask와 함께 동작합니다. 이제 Solana 지갑이 이미 가진 키로 그것을 호출하게 하여, 사용자가 EVM 계정을 만들지 않도록 합니다. 그들은 같은 상태를 대상으로, 같은 주소에서, 같은 계약을 호출합니다.

## 배울 내용

* Solana 지갑이 일반적인 `msg.sender` 가 되는 방법.
* 이 과정이 ERC-20 예치금으로 가치를 받는 이유와 `msg.value` Solana 사용자로부터 무엇이 필요한지.
* Solana 사용자가 각 호출마다 무엇에 서명하는지, 그리고 거래가 어디로 가는지.
* 하나의 Solana 트랜잭션에 무엇이 들어가고, 그렇지 않은 호출에는 무슨 일이 일어나는지.
* 어떤 `의존성이` SDK에 필요하고 각각이 어디에서 오는지.

## 시작하기 전에

* 완료 [6. 양쪽의 토큰](https://docs.rome.builders/ko/rome/06-tokens-on-both-sides.md). 이 레슨은 래퍼가 무엇인지, 그리고 사용자가 왜 그것에 한 번 권한을 부여하는지 알고 있다고 가정합니다.
* 다음이 있어야 합니다: `HelloRome` 가 Hadrian에 배포되어 있음 [3. Hadrian에서의 첫 컨트랙트](https://docs.rome.builders/ko/rome/03-first-contract-on-hadrian.md).
* TS SDK를 설치합니다, 다음에서처럼 [Rome SDK](https://docs.rome.builders/ko/products/rome-sdk.md#typescript-sdk-rome-protocol-sdk).
* Solana v1 트랜잭션에 서명하는 Solana 지갑이 있고, 약간의 devnet SOL과 devnet USDC가 있어야 합니다. Faucet는 다음에 나열되어 있습니다 [파우셋](https://docs.rome.builders/ko/resources/faucets.md). v1 트랜잭션 지원은 지갑마다 다르므로, 먼저 본인의 지갑에서 테스트하세요. [듀얼 레인 앱 빌드](https://docs.rome.builders/ko/developer-guides/dual-lane-app.md) 지금까지 확인된 지갑들을 나열합니다.

## 이 레슨

### 1단계. 합성 주소 만나기

Solana 지갑에는 EVM 주소가 없으므로, Rome은 공개 키에서 하나를 도출합니다. 그 결과가 지갑의 합성 주소입니다. 그것은 `msg.sender` 당신의 계약이 보는 주소이며, 다른 계정과 마찬가지로 자체 nonce와 storage를 가집니다. 같은 지갑은 항상 같은 주소로 매핑됩니다.

```javascript
import { syntheticAddress } from "@rome-protocol/sdk";
const from = syntheticAddress(solanaPubkey); // 일반적인 20바이트 주소
```

이 과정의 흐름에서는 합성이 휴지 상태에서 토큰을 보유하지 않습니다. 토큰은 사용자의 Solana 지갑에서 시작합니다. 자금 이동 단계는 예치 전에 토큰을 합성의 토큰 계정으로 옮기고, 그때서야 래퍼의 `balanceOf(synthetic)` 이 표시됩니다. 스윕 단계는 출금 후 토큰을 지갑으로 다시 옮깁니다. 전체 모델은 다음에서 읽어보세요 [Solana에서 EVM 호출](https://docs.rome.builders/ko/developer-guides/call-evm-from-solana.md#synthetic-addresses).

### 2단계. 계약을 Solana용으로 만들기

대부분의 계약은 변경이 필요 없습니다. 다음 세 가지 규칙이 귀하의 계약이 그런지 여부를 결정합니다:

* ERC-20으로 가치를 받으세요. 이후 `transferFrom` 을 `approve`한 뒤 사용하고, 다음으로 돌려보내세요 `transfer`.
* 각 토큰에 대해 정식 래퍼를 가리키세요. 직접 배포하지 마세요.
* 각 Solana-레인 호출은 하나의 Solana 트랜잭션 안에 넣으세요.

첫 번째 규칙이 가장 문제를 일으킵니다. 이 진입점은 MetaMask 사용자는 잘 동작합니다. 하지만 자금 이동 및 스윕 모델의 Solana 사용자에게는 실패하는데, 그들의 합성에는 네이티브 잔액이 없기 때문입니다. 이를 충전하지 않으면 `fundSyntheticGas`:

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

이것은 둘 다에서 동작합니다. 왜냐하면 두 레인 모두 `transferFrom`:

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

래퍼 주소는 [Contract Addresses](https://docs.rome.builders/ko/reference/contract-addresses.md)에 있습니다. Solana용 계약인지 확인하는 기준은 [Solidity 계약을 Solana 사용자에게 열어보세요](https://docs.rome.builders/pages/d701f73a420f5be573a67faa520cc3fe069d9bfc#id-2.-what-makes-a-contract-solana-ready).

### 3단계. 지갑이 무엇에 서명하는지 이해하기

SDK 호출은 `submitRomeTxV1`. 각 호출마다 프록시는 하나의 Solana v1 트랜잭션을 구성합니다. 지갑은 같은 키로 두 번 서명합니다. 먼저 EVM 트랜잭션 해시를 명시한 읽기 가능한 승인 메시지에 서명합니다. 그런 다음 트랜잭션 자체에 서명합니다.

앱은 서명된 트랜잭션을 Rome 프록시가 아니라 Solana RPC로 보냅니다. 체인은 Ed25519 프로그램을 통해 승인을 확인하고, 당신의 호출을 합성 주소로 실행합니다. 사용자는 EVM 키를 절대 보유하지 않습니다.

지갑이 트랜잭션에 서명하기 전에, SDK는 사용자가 승인한 호출과 정확히 같은 호출이 담겨 있는지 확인합니다. 그 외의 것은 거부됩니다. 자세한 내용은 [Solidity 계약을 Solana 사용자에게 열어보세요](https://docs.rome.builders/pages/d701f73a420f5be573a67faa520cc3fe069d9bfc#id-3.-let-a-solana-wallet-call-it).

### 4단계. 레인 연결하기

SDK에는 다섯 값이 필요합니다: 프록시 URL, 체인 ID, Rome 프로그램 ID, Solana RPC 연결, 그리고 서명자. 네 개는 체인을 설명합니다. 하나는 지갑에서 옵니다.

```javascript
const deps = { connection, proxyUrl, chainId, programId, signer };
const res = await submitRomeTxV1(deps, { to: helloRome, data }); // helloRome: 3단계 레슨의 계약; data: ABI로 인코딩된 greet() 호출
```

Hadrian의 경우, 레지스트리에서 네 개의 체인 값을 읽으세요. 매핑은 다음에 있습니다 `의존성이` 3단계에 링크된 가이드의 표이며, 값들은 다음에 있습니다 [Hadrian](https://docs.rome.builders/ko/networks/hadrian.md). 11단계에서는 Rubicon에 대해 같은 연결 작업을 다룹니다.

새 사용자의 첫 번째 가치 이동 호출 전에 두 가지 일회성 단계가 필요합니다. 다음으로 합성을 준비하세요 `buildCreatePdaCall`, 그리고 만약 `isEnabled` 가 false라면 래퍼를 권한 부여하세요. `submitRomeTxV1` 는 대신 자동으로 준비해주지 않습니다. 9단계에서 둘 다 순서대로 실행합니다.

### 5단계. 하나의 트랜잭션 안에 머물기

Solana-레인 호출은 하나의 Solana 트랜잭션에 들어가야 합니다: 대략 140만 compute unit, 64개 계정, 4KB입니다. 측정은 EVM의 `computeUnitsConsumed` 가 아니라 Solana 영수증에서 하세요 `gasUsed`. 트랜잭션 요청에는 `maxSupportedTransactionVersion: 1`을 사용하세요. 이것이 없으면 RPC가 요청을 거부합니다.

호출이 맞지 않으면, 컴포저가 이를 거부하고 SDK가 같은 승인 서명으로 프록시에 넘겨 릴레이합니다. 사용자는 여전히 하나의 프롬프트만 봅니다. 결과에는 `route: "relay"`가 포함됩니다. 릴레이된 호출은 합성의 네이티브 가스를 사용하므로, 먼저 다음으로 충전하세요 `fundSyntheticGas`되돌아간 릴레이 호출은 예외를 던지지 않습니다. 다음을 확인하세요 `receipt.status`. 규칙은 다음에 있습니다 [릴레이된 호출과 긴 호출](https://docs.rome.builders/ko/developer-guides/call-evm-from-solana.md#relayed-calls-and-long-calls). 한 표의 제한: [제약](https://docs.rome.builders/ko/core-concepts/constraints.md).

## 직접 확인해보세요

이것들에 답한 다음, 정답을 열어보세요.

1. 왜 `payable` 예치가 Solana 사용자에게 실패할까요?
2. 지갑은 호출당 몇 개의 서명을 생성하며, 각 서명은 무엇을 다루나요?
3. 서명된 트랜잭션은 어디로 가나요?
4. 호출에 하나보다 많은 트랜잭션이 필요합니다. 사용자는 무엇을 보고, 누가 비용을 지불하나요?

<details>

<summary>정답</summary>

1. 사용자의 자금은 지갑에 있는 SPL 토큰이며, Rome에서는 래퍼로 표시됩니다. 합성은 자금 이동 및 스윕 모델에서 충전하지 않는 한 네이티브 잔액을 전혀 보유하지 않으므로, 보낼 `msg.value` 것이 없습니다.
2. 두 개입니다. 첫 번째는 EVM 트랜잭션 해시가 포함된 읽기 가능한 승인 메시지를 다룹니다. 두 번째는 Solana 트랜잭션을 다룹니다.
3. 앱이 보낸 Solana RPC로 갑니다. 프록시는 릴레이된 호출이 아닌 이상 트랜잭션을 구성만 할 뿐 받지 않습니다.
4. 하나의 승인 프롬프트입니다. 프록시가 호출을 릴레이하고 합성의 네이티브 가스 잔액이 비용을 지불합니다.

</details>

## 다음

[8. Solana 프로그램을 EVM 사용자에게 개방하기](https://docs.rome.builders/ko/rome/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/ko/rome/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.
