> 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/tr/gelistirici-kilavuzlari/call-solana-from-evm.md).

# EVM'den Solana'yı çağırma

Rome'un CPI'si ve yardımcı precompile'ları aracılığıyla Solidity'den Solana programlarını çağırın.

Rome'un ön-derlemeleri Solidity sözleşmelerinin Solana programlarını doğrudan çağırmasına izin verir. Bu kılavuz mekanikleri kapsar.

## Ön koşullar

* Genel depodan alınan Rome Solidity arayüzleri [`rome-solidity`](https://github.com/rome-protocol/rome-solidity) repo (GitHub'dan kurulmuş, npm'den değil — bkz. [Solidity'yi dağıtın](https://docs.rome.builders/tr/gelistirici-kilavuzlari/deploy-solidity.md#using-the-rome-solidity-sdk)) — ön-derleme arayüzleri şu konumda bulunur: [`contracts/interface.sol`](https://github.com/rome-protocol/rome-solidity/blob/master/contracts/interface.sol)
* Dağıtılmış bir Rome sözleşmesi (bkz. [Solidity'yi dağıtın](https://docs.rome.builders/tr/gelistirici-kilavuzlari/deploy-solidity.md))

Her arayüzü kendi ön-derleme adresine bağlayın:

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

ICrossProgramInvocation constant CpiProgram    = ICrossProgramInvocation(0xFF00000000000000000000000000000000000008);
ISystemProgram          constant SystemProgram = ISystemProgram(0xFF00000000000000000000000000000000000007);
IHelperProgram          constant Helper        = IHelperProgram(0xFF00000000000000000000000000000000000009);
```

## CpiProgram ön-derlemesi

`CpiProgram` (`0xFF…08`) CPI'yi (`invoke` / `invoke_signed`) ve çapraz durum okuma kısayollarını (`account_info`, `account_data_at`, `account_u64_at`, `account_lamports`, `pdas_batch_derive`):

```solidity
// Bir Solana programını çağırın
CpiProgram.invoke(programId, accounts, instructionData);

// PDA imzasıyla çağırın: sözleşmenizin dış yetki PDA'sı imzalar, ayrıca bir
// `salts` içindeki her giriş için tuzlanmış alt-PDA (Rome ["EXTERNAL_AUTHORITY", contract, salt] türetir)
CpiProgram.invoke_signed(programId, accounts, data, salts);
```

## Lamport transfer etme

Basit lamport ve SPL transferleri için HelperProgram ön-derlemesini kullanın — elle oluşturulmuş CPI gerekmez. Ona çağrı yapan bir sözleşme, **kendisinin**: aşağıdaki transferler sözleşmenin kendi lamport ve token'larını taşır (dış yetki PDA'sı imzalar), kullanıcınınkileri değil. Bir sözleşmenin kullanıcının SPL token'larını kontrol ettiği bir token hesabına çekmesi ve bunların kimin olduğunu bilmesi için kullanıcı bir SPL delege etme izni verir. Bir ERC-20 `transfer` veya `transferFrom`  bir sözleşmeye verildiğinde yalnızca sarmalayıcının emanet defterini kredilendirir ve sözleşmeye harcayabileceği bir token hesabı sağlamaz — bkz. [Bir Solana programını entegre edin](https://docs.rome.builders/tr/gelistirici-kilavuzlari/integrate-solana-program.md).

```solidity
contract Transfers {
    IHelperProgram constant Helper = IHelperProgram(0xFF00000000000000000000000000000000000009);

    // Lamportları bu sözleşmenin PDA'sından bir EVM adresinin PDA'sına aktarın
    function transferSol(address to, uint64 lamports) external {
        Helper.transfer_lamports(to, lamports);
    }

    // Bu sözleşmenin PDA'sına ait token hesabından bir SPL token aktarın
    function transferSpl(address to, uint64 tokens, bytes32 mint) external {
        Helper.transfer_spl(to, tokens, mint);
    }

    // Bir mint için çağıranın ATA'sını oluşturun
    function createAta(bytes32 mint) external {
        Helper.create_ata(msg.sender, mint);
    }
}
```

`transfer_spl` birden çok aşırı yüklemeye sahiptir ( `transferFrom` akışları için `interface.sol`. Önbelleğe alınmış hatta, bunun yerine `ISplCached` (`0xff…05`) / `IAssociatedSplCached` (`0xff…06`) kullanın — bir sözleşme tek bir hattı tutarlı şekilde kullanır ve yalnızca eski hat `invoke`  özel bir programı (bkz. [Bir Solana programını entegre edin](https://docs.rome.builders/tr/gelistirici-kilavuzlari/integrate-solana-program.md)).

## Hesap verilerini okuma

CpiProgram okuma kısayolları aracılığıyla herhangi bir Solana hesabının verisini okuyun:

```solidity
(
    uint64 lamports,
    bytes32 owner,
    bool isSigner,
    bool isWritable,
    bool executable,
    bytes memory data
) = CpiProgram.account_info(accountPubkey);
```

## PDA türetme

System ön-derlemesi aracılığıyla Solidity'den Program Türetilmiş Adresleri bulun:

```solidity
ISystemProgram.Seed[] memory seeds = new ISystemProgram.Seed[](2);
seeds[0] = ISystemProgram.Seed("my-program-seed");
seeds[1] = ISystemProgram.Seed(abi.encodePacked(someValue));

(bytes32 pda, uint8 bump) = SystemProgram.find_program_address(targetProgramId, seeds);
```

## Base58 dönüşümü

Arasında dönüştürün `bytes32` ve base58 (Solana'nın adres formatı):

```solidity
bytes memory base58Str = SystemProgram.bytes32_to_base58(pubkey);
bytes32 pubkey = SystemProgram.base58_to_bytes32(base58Bytes);
```

## Özel Solana programlarını çağırma

Herhangi bir Solana programını çağırmak için, hesap listesini ve talimat verisini kendiniz oluşturun:

```solidity
contract CustomCPI {
    ICrossProgramInvocation constant CpiProgram = ICrossProgramInvocation(0xFF00000000000000000000000000000000000008);
    bytes32 constant MY_PROGRAM = 0x0000000000000000000000000000000000000000000000000000000000000000; // your Solana program ID

    function callMyProgram(bytes32 account1, bytes32 account2, bytes calldata ixData) external {
        ICrossProgramInvocation.AccountMeta[] memory accounts = new ICrossProgramInvocation.AccountMeta[](2);
        accounts[0] = ICrossProgramInvocation.AccountMeta(account1, false, true);
        accounts[1] = ICrossProgramInvocation.AccountMeta(account2, false, false);

        CpiProgram.invoke(MY_PROGRAM, accounts, ixData);
    }
}
```

## Temel Kısıtlamalar

1. **Tüm hesaplar önceden beyan edilmelidir.** Solana işlemi, CPI'ın dokunacağı her hesabı içermelidir — CPI içinde dinamik hesap keşfi mümkün değildir.
2. **CPI derinlik sınırı: 4 seviye.** Rome EVM → hedefiniz → hedefin çağrısı → bir tane daha. Çağrı derinliğinizi planlayın.
3. **Solana pubkey'leri `bytes32`,** 20 baytlık Ethereum adresleri değildir.
4. **Talimat verisi ham baytlardır** hedef programın beklediği formatta (genellikle Borsh, little-endian).

## Sırada Ne Var

* **Gerçek bir uygulamada görün** — [cardo](https://github.com/rome-protocol/cardo) ara sözleşme olmadan, doğrudan kullanıcının cüzdanından ön-derlemeye CPI çağrıları gönderir; [rome-dex](https://github.com/rome-protocol/rome-dex) (çift hatlı AMM) aynı şeyi yapar ve ayrıca emanetsiz bir yönlendirici sözleşmeye sahiptir; [aerarium](https://github.com/rome-protocol/aerarium) Solidity'den Solana programlarını çağırmayan bir borç verme uygulamasıdır.
* [Bir Solana programını entegre edin](https://docs.rome.builders/tr/gelistirici-kilavuzlari/integrate-solana-program.md) — kullanıcının Solana kimliği, onun adına imzalaması, tek hat kuralı ve diğer taraftaki gerçek bir program için hesap sağlama
* [Precompile referansı](https://docs.rome.builders/tr/referans/precompiles.md) — her ön-derleme üzerindeki her seçici
* [Solana'dan EVM'yi çağırma](https://docs.rome.builders/tr/gelistirici-kilavuzlari/call-evm-from-solana.md) — bunun tersi: EVM sözleşmelerini bir Solana cüzdanından çalıştırın
* [Token Birlikte Çalışabilirliği](https://docs.rome.builders/tr/temel-kavramlar/token-interop.md) — ERC-20 ve SPL token'larının birlikte nasıl çalıştığı
* [Kısıtlar](https://docs.rome.builders/tr/temel-kavramlar/constraints.md) — CPI derinliği ve diğer sınırlar


---

# 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/tr/gelistirici-kilavuzlari/call-solana-from-evm.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.
