> 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/de/entwicklerleitfaden/call-solana-from-evm.md).

# Solana aus EVM aufrufen

Romes Precompiles ermöglichen es Solidity-Contracts, Solana-Programme direkt aufzurufen. Dieser Leitfaden erklärt die Funktionsweise.

## Voraussetzungen

* Die Rome-Solidity-Interfaces aus dem öffentlichen [`rome-solidity`](https://github.com/rome-protocol/rome-solidity) Repository (Veröffentlichung auf npm ausstehend) — die Precompile-Interfaces befinden sich in [`contracts/interface.sol`](https://github.com/rome-protocol/rome-solidity/blob/master/contracts/interface.sol)
* Ein bereitgestellter Rome-Contract (siehe [Solidity bereitstellen](/de/entwicklerleitfaden/deploy-solidity.md))

Binde jedes Interface an seine Precompile-Adresse:

```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);
```

## Das CpiProgram-Precompile

`CpiProgram` (`0xFF…08`) führt CPI (`invoke` / `invoke_signed`) plus Cross-State-Leseabkürzungen (`account_info`, `account_data_at`, `account_u64_at`, `account_lamports`, `pdas_batch_derive`):

```solidity
// Solana-Programm aufrufen
CpiProgram.invoke(programId, accounts, instructionData);

// Mit PDA-Signierung aufrufen (dein Contract signiert als PDA)
CpiProgram.invoke_signed(programId, accounts, data, seeds);
```

## Lamports übertragen

Für einfache SOL/Lamports- und SPL-Übertragungen aus der PDA des Aufrufers verwende das HelperProgram-Precompile — kein manuell aufgebautes CPI nötig:

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

    // Lamports an die PDA einer EVM-Adresse übertragen
    function transferSol(address to, uint64 lamports) external {
        Helper.transfer_lamports(to, lamports);
    }

    // Einen SPL-Token aus der PDA des Aufrufers übertragen
    function transferSpl(address to, uint64 tokens, bytes32 mint) external {
        Helper.transfer_spl(to, tokens, mint);
    }

    // Erstelle die ATA des Aufrufers für einen Mint
    function createAta(bytes32 mint) external {
        Helper.create_ata(msg.sender, mint);
    }
}
```

`transfer_spl` hat mehrere Überladungen (einschließlich einer Delegate-Variante für `transferFrom` Flows); siehe `interface.sol`. Im gecachten Pfad verwende `ISplCached` (`0xff…05`) / `IAssociatedSplCached` (`0xff…06`) stattdessen — ein Contract verwendet konsequent einen Pfad.

## Kontodaten lesen

Lese die Daten eines beliebigen Solana-Kontos über die Leseabkürzungen von CpiProgram:

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

## PDA-Ableitung

Finde Program Derived Addresses aus Solidity über das System-Precompile:

```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-Konvertierung

Konvertiere zwischen `bytes32` und Base58 (Solanas Adressformat):

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

## Benutzerdefinierte Solana-Programme aufrufen

Um ein beliebiges Solana-Programm aufzurufen, stelle die Kontoliste und die Instruktionsdaten selbst zusammen:

```solidity
contract CustomCPI {
    ICrossProgramInvocation constant CpiProgram = ICrossProgramInvocation(0xFF00000000000000000000000000000000000008);
    bytes32 constant MY_PROGRAM = 0x0000000000000000000000000000000000000000000000000000000000000000; // deine Solana-Programm-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);
    }
}
```

## Wichtige Einschränkungen

1. **Alle Konten müssen im Voraus angegeben werden.** Die Solana-Transaktion muss jedes Konto enthalten, das CPI berühren wird — dynamische Kontoerkennung innerhalb von CPI ist nicht möglich.
2. **CPI-Tiefenlimit: 4 Ebenen.** Rome EVM → dein Ziel → der Aufruf des Ziels → noch einer mehr. Plane deine Aufruftiefe.
3. **Solana-Pubkeys sind `bytes32`,** keine 20-Byte-Ethereum-Adressen.
4. **Instruktionsdaten sind rohe Bytes** im Format, das das Zielprogramm erwartet (typischerweise Borsh, Little-Endian).

## Was kommt als Nächstes

* **Sieh es in einer echten App** — [rome-dex](https://github.com/rome-protocol/rome-dex) (Dual-Lane-AMM), [cardo](https://github.com/rome-protocol/cardo) (CPI-Routen zu Meteora / Marinade / Mango / Jupiter), und [aerarium](https://github.com/rome-protocol/aerarium) in Produktion Solana aus Solidity aufrufen.
* [EVM aus Solana aufrufen](/de/entwicklerleitfaden/call-evm-from-solana.md) — das Gegenteil: EVM-Contracts von einer Solana-Wallet aus steuern
* [Token-Interop](/de/kernkonzepte/token-interop.md) — wie ERC-20- und SPL-Token zusammenarbeiten
* [Einschränkungen](/de/kernkonzepte/constraints.md) — CPI-Tiefe und andere Begrenzungen


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rome.builders/de/entwicklerleitfaden/call-solana-from-evm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
