# Rome SDK

Das Rome SDK stellt typisierte Solidity-Schnittstellen bereit, um von EVM-Smart-Contracts aus mit Solana-Programmen zu interagieren. Es ist das Entwickler-Toolkit zum Erstellen von Cross-Runtime-Anwendungen auf Rome.

## Zwei SDKs

Rome hat zwei SDKs, die unterschiedlichen Zwecken dienen:

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

**Für Solidity-Entwickler.** Stellt Precompile-Schnittstellen, ERC-20/SPL-Wrapper, PDA-Ableitung und CPI-Dienstprogramme bereit. Installation über npm und Import in Ihre Solidity-Contracts.

```bash
npm install @rome-protocol/solidity-sdk
```

```solidity
import {SplToken, CpiProgram, SystemProgram} from "@rome-protocol/solidity-sdk/contracts/core/Precompiles.sol";
import {SPL_ERC20} from "@rome-protocol/solidity-sdk/contracts/token/ERC20SPL.sol";
import {RomeEVMAccount} from "@rome-protocol/solidity-sdk/contracts/core/RomeEVMAccount.sol";
```

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

**Für Infrastrukturbetreiber.** Ein Rust-Workspace aus 9 Crates, der Transaktionszusammenstellung, Solana-Interaktion, Gaspreisgestaltung, Blockindizierung und Service-Orchestrierung übernimmt. Verwendet von Proxy, Hercules und Rhea.

## Solidity SDK: Was enthalten ist

### Precompile-Schnittstellen

Vorgebundene Singleton-Konstanten für alle Rome-Precompiles:

```solidity
// Nach dem Import global verfügbar
ISplToken constant SplToken;                    // 0xff...05
IAssociatedSplToken constant AssociatedSplToken; // 0xff...06
ISystemProgram constant SystemProgram;           // 0xff...07
ICrossProgramInvocation constant CpiProgram;     // 0xff...08
IWithdraw constant Withdraw;                     // 0x42...16
```

### SPL-Token-Operationen

```solidity
// Tokenkontostatus lesen
ISplToken.Account memory acc = SplToken.account_state(tokenAccountPubkey);
uint64 balance = acc.amount;
bytes32 owner = acc.owner;

// Tokens übertragen
SplToken.transfer(recipientAta, mintPubkey, amount);

// Ein neues Tokenkonto initialisieren
SplToken.initialize_account3(newAccount, mintPubkey, ownerPubkey);
```

### PDA-Ableitung

```solidity
// Ein Solana-PDA eines Benutzers ableiten
bytes32 userPda = RomeEVMAccount.pda(msg.sender);

// PDA mit Salt ableiten (um mehrere PDAs pro Benutzer zu erstellen)
bytes32 pda = RomeEVMAccount.pda_with_salt(msg.sender, salt);

// Beliebiges PDA finden
(bytes32 pda, uint8 bump) = SystemProgram.find_program_address(programId, seeds);
```

### Cross-Program Invocation

```solidity
// Beliebiges Solana-Programm aufrufen
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);

// Mit PDA-Signierung aufrufen
CpiProgram.invoke_signed(programId, accounts, data, seeds);

// Kontodaten lesen
(uint64 lamports, bytes32 owner, bool isSigner, bool isWritable, bool executable, bytes memory data)
    = CpiProgram.account_info(pubkey);
```

### ERC-20 auf SPL-Tokens

```solidity
// Wrapper für beliebiges SPL-Mint bereitstellen
ERC20SPLFactory factory = ERC20SPLFactory(FACTORY_ADDRESS);
address wrapper = factory.add_spl_token_with_metadata(splMint);

// Den Wrapper als standardmäßiges ERC-20 verwenden
SPL_ERC20 token = SPL_ERC20(wrapper);
token.transfer(recipient, amount);
uint256 balance = token.balanceOf(user);
```

### Token-Registry

```solidity
TokenRegistry registry = TokenRegistry(REGISTRY_ADDRESS);

// Mit Cross-Chain-Metadaten registrieren
registry.registerToken(splMint, TokenOrigin.WormholeWrapped, externalAddr, chainId);

// Nach externem Token nachschlagen
TokenEntry memory entry = registry.getTokenByExternal(2, ethUsdcAddress);
```

### Borsh-Deserialisierung

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

// Solana-Kontodaten parsen (Little-Endian-Borsh-Format)
(uint64 value, uint256 newOffset) = Convert.read_u64le(data, offset);
(bytes32 pubkey, uint256 newOffset2) = Convert.read_bytes32(data, offset);
```

### Metaplex-Metadaten

```solidity
import {MplTokenMetadataLib} from "@rome-protocol/solidity-sdk/contracts/programs/metadata/MplTokenMetadataLib.sol";

// Token-Metadaten von Metaplex laden
MplTokenMetadataLib.Metadata memory meta = MplTokenMetadataLib.load_metadata(
    mintPubkey, mplProgramId, cpiAddress
);
string memory name = meta.name;
string memory symbol = meta.symbol;
```

## Rust SDK: Architektur

Das Rust SDK ist ein Workspace mit 9 Crates:

| Crate             | Zweck                                                                           |
| ----------------- | ------------------------------------------------------------------------------- |
| `rome-sdk`        | Kern-API: `Rome` struct, config, Transaktionstypen (RheaTx, RemusTx, RomulusTx) |
| `rome-evm-client` | EVM-Rollup-Client, TxBuilder, ResourceFactory, Emulator-Integration             |
| `rome-solana`     | Solana-Tower, RPC-Client, Transaktionsbündelung und -verfolgung                 |
| `rome-geth`       | OP-Geth Engine API-Integration für den Blockaufbau                              |
| `rome-utils`      | RLP-, Hex-, JSON-RPC-, Authentifizierungs-Dienstprogramme                       |
| `rome-obs`        | OpenTelemetry-Observability (Traces, Metriken, Logs)                            |
| `rome-da`         | Celestia-Datenverfügbarkeitsschicht                                             |
| `rome-meteora`    | Meteora DEX AMM-Pool-Adapter für die Gaspreisgestaltung                         |
| `rome-meta-hook`  | Client für Token-2022 Transfer-Hook-Router                                      |

### Transaktionstypen

```rust
// Einzelne Rollup-Transaktion
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?;

// Atomare Cross-Rollup-Transaktion
let remus = RemusTx::new(vec![tx1, tx2]);
let mut tx = rome.compose_cross_rollup_tx(remus).await?;

// Atomare Cross-Chain-Transaktion (EVM + Solana)
let romulus = RomulusTx::new(eth_txs, sol_ixs);
let mut tx = rome.compose_cross_chain_tx(romulus, signers).await?;
```

### Ressourcenpooling

Das SDK poolt Solana-Keypairs (Zahler) und Holder-Kontoindizes für parallele Transaktionseinreichung:

```rust
let resource = resource_factory.get().await?;
let payer = resource.payer();       // Solana-Keypair
let holder = resource.holder();     // Holder-Kontoindex
// Ressource wird beim Drop automatisch an den Pool zurückgegeben
```

## SDK-Roadmap

### Erstellt und funktionsfähig

* SPL-Token-Wrapper und Precompile-Schnittstellen
* Meteora DAMM v1 Swaps via CPI
* Oracle Gateway V1 + V2 (Pyth Pull, Switchboard V3)
* System-Program-Helper, Borsh-Deserialisierung
* ERC20SPL Factory + Bridge-Contracts
* Token-Registry mit Cross-Chain-Metadaten

### In Arbeit

* JupiterRouter (Solidity-Schnittstelle für Jupiter-Swaps)
* Meta-Hook Router SDK-Client

### Geplant (Phase 2)

| Schnittstelle | Protokoll              |
| ------------- | ---------------------- |
| IJupiter      | Jupiter DEX-Aggregator |
| IDrift        | Drift-Perpetuals       |
| IKamino       | Kamino Lending         |
| IMeteora      | Meteora-Liquidität     |
| IOndoGM       | Ondo RWA               |

### Geplant (Phase 3)

| Schnittstelle | Programm          |
| ------------- | ----------------- |
| IStakeProgram | Solana Stake      |
| IVoteProgram  | Solana Vote       |
| ISlotHashes   | SlotHashes-Sysvar |

## Was kommt als Nächstes

* [Solidity bereitstellen](/de/entwicklerhandbucher/deploy-solidity.md) — stellen Sie Ihren ersten Contract mithilfe des SDK bereit
* [Solana von EVM aus aufrufen](/de/entwicklerhandbucher/call-solana-from-evm.md) — verwenden Sie CPI, um mit Solana-Programmen zu interagieren
* [Contract-Adressen](/de/referenz/contract-addresses.md) — bereitgestellte SDK-Contract-Adressen


---

# Agent Instructions: 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:

```
GET https://docs.rome.builders/de/produkte/rome-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
