# Solidity-Verträge bereitstellen

Dieser Leitfaden behandelt die Bereitstellung von Solidity-Smart-Contracts auf Rome EVM mit Hardhat und Foundry.

## Voraussetzungen

* Node.js v18+ (Hardhat) oder Foundry installiert
* Eine finanzierte Rome-EVM-Adresse (siehe [Quickstart](/de/erste-schritte/quickstart.md))
* Dein privater Schlüssel, als Umgebungsvariable exportiert

```bash
export PRIVATE_KEY="0xYOUR_PRIVATE_KEY"
```

## Netzwerkkonfiguration

| Netzwerk          | RPC-URL                                      | Chain-ID |
| ----------------- | -------------------------------------------- | -------- |
| Lokal             | `http://localhost:9090`                      | `1001`   |
| Devnet (montispl) | `https://montispl.devnet.romeprotocol.xyz`   | `200002` |
| Testnet (Martius) | `https://martius-i.testnet.romeprotocol.xyz` | `121214` |
| Testnet (Caelian) | `https://caelian-i.testnet.romeprotocol.xyz` | `121215` |

## Hardhat

### Einrichtung

```bash
mkdir my-rome-project && cd my-rome-project
npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init
```

### hardhat.config.js

```javascript
require("@nomicfoundation/hardhat-toolbox");

module.exports = {
  solidity: {
    version: "0.8.28",
    settings: {
      optimizer: { enabled: true, runs: 200 },
    },
  },
  networks: {
    rome_local: {
      url: "http://localhost:9090",
      chainId: 1001,
      accounts: [process.env.PRIVATE_KEY],
    },
    rome_devnet: {
      url: "https://montispl.devnet.romeprotocol.xyz",
      chainId: 200002,
      accounts: [process.env.PRIVATE_KEY],
    },
    rome_martius: {
      url: "https://martius-i.testnet.romeprotocol.xyz",
      chainId: 121214,
      accounts: [process.env.PRIVATE_KEY],
    },
    rome_caelian: {
      url: "https://caelian-i.testnet.romeprotocol.xyz",
      chainId: 121215,
      accounts: [process.env.PRIVATE_KEY],
    },
  },
};
```

### Bereitstellen

```bash
npx hardhat run scripts/deploy.js --network rome_devnet
```

### Auf dem Block-Explorer verifizieren

```bash
npx hardhat verify --network rome_martius 0xCONTRACT_ADDRESS
```

## Foundry

### Einrichtung

```bash
forge init my-rome-project
cd my-rome-project
```

### Bereitstellen

```bash
# Lokal
forge create --rpc-url http://localhost:9090 \\
  --private-key $PRIVATE_KEY \\
  src/Counter.sol:Counter

# Devnet
forge create --rpc-url https://montispl.devnet.romeprotocol.xyz \\
  --private-key $PRIVATE_KEY \\
  src/Counter.sol:Counter
```

### Bereitgestellten Contract aufrufen

```bash
# Lesen
cast call 0xCONTRACT_ADDRESS "number()" \\
  --rpc-url https://montispl.devnet.romeprotocol.xyz

# Schreiben
cast send 0xCONTRACT_ADDRESS "increment()" \\
  --rpc-url https://montispl.devnet.romeprotocol.xyz \\
  --private-key $PRIVATE_KEY
```

## Verwendung des Rome Solidity SDK

Für Contracts, die mit Solana-Programmen interagieren, installiere das Rome Solidity SDK:

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

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

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";

contract MyRomeContract {
    // Lese das SPL-Token-Guthaben des Benutzers von Solana aus
    function getSolanaBalance(bytes32 mint) external view returns (uint64) {
        bytes32 userPda = RomeEVMAccount.pda(msg.sender);
        ISplToken.Account memory account = SplToken.account_state(userPda);
        return account.amount;
    }

    // Rufe ein beliebiges Solana-Programm per CPI auf
    function callSolanaProgram(
        bytes32 programId,
        ICrossProgramInvocation.AccountMeta[] calldata accounts,
        bytes calldata data
    ) external {
        CpiProgram.invoke(programId, accounts, data);
    }
}
```

## Bereitstellungsbeschränkungen

| Beschränkung                | Limit                  | Hinweise                                                                |
| --------------------------- | ---------------------- | ----------------------------------------------------------------------- |
| Maximale Contract-Größe     | 480 KB                 | Erhöht von Ethereums 24 KB für den OP-Geth-Modus                        |
| Limit der Transaktionsgröße | 80 KB pro Holder       | Große Bereitstellungen werden transparent über Holder-Konten aufgeteilt |
| Compute-Budget              | \~1,4 Mio. CU (atomar) | Verwende den iterativen Modus für aufwendige Contracts                  |
| Solidity-Version            | 0.8.28 empfohlen       | Frühere Versionen funktionieren, aber 0.8.28 passt zum SDK              |

## Häufige Fehler

| Fehler                            | Ursache                           | Behebung                                                      |
| --------------------------------- | --------------------------------- | ------------------------------------------------------------- |
| `nicht genügend Guthaben für Gas` | Die EVM-Adresse hat kein Guthaben | Zahle SOL über die Einzahlungs-UI ein                         |
| `Nonce zu niedrig`                | Veraltete Nonce in der Wallet     | Setze das MetaMask-Konto zurück oder gib die Nonce manuell an |
| `Ausführung rückgängig gemacht`   | Contract-Logik fehlgeschlagen     | Debuggen mit `eth_call` oder `forge test --fork-url`          |
| `Transaktion zu niedrig bepreist` | Gaspreis unter dem Minimum        | Erhöhe den Gaspreis in der Transaktion                        |

## Was kommt als Nächstes

* [Solana von EVM aus aufrufen](/de/entwicklerhandbucher/call-solana-from-evm.md) — verwende CPI-Precompiles, um mit Solana-Programmen zu interagieren
* [Token-Wrapping](https://github.com/rome-protocol/docs/blob/main/developer-guides/token-wrapping.md) — stelle ERC-20-Wrappers für SPL-Token bereit
* [CU-Optimierung](https://github.com/rome-protocol/docs/blob/main/developer-guides/cu-optimization.md) — reduziere den Verbrauch von Compute Units


---

# 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/entwicklerhandbucher/deploy-solidity.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.
