> 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/deploy-solidity.md).

# Solidity-Verträge bereitstellen

Stelle Solidity-Smart-Contracts auf Solana mit Hardhat oder Foundry bereit — Rome-Netzwerkkonfiguration, aufgeladene Accounts und schrittweise Bereitstellung.

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

## Voraussetzungen

* Node.js v22.13+ (Hardhat) oder Foundry installiert
* Eine finanzierte Rome-EVM-Adresse (siehe [Schnellstart](https://docs.rome.builders/de/erste-schritte-1/quickstart.md))
* Dein privater Schlüssel, als Umgebungsvariable exportiert

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

## Netzwerkkonfiguration

| Netzwerk              | RPC-URL                                     | Chain-ID | Explorer                               |
| --------------------- | ------------------------------------------- | -------- | -------------------------------------- |
| Hadrian (Testnetz)    | `https://hadrian.testnet.romeprotocol.xyz/` | `200010` | `via-hadrian.testnet.romeprotocol.xyz` |
| **Rubicon (Mainnet)** | `https://rubicon.mainnet.romeprotocol.xyz/` | `7531`   | `via-rubicon.mainnet.romeprotocol.xyz` |

Gas ist auf jedem Netzwerk USDC. Auf Hadrian erhältst du es durch das Bridgen von Test-USDC oder durch das Wrappen aus einer Solana-Devnet-Wallet ([Faucets](https://docs.rome.builders/de/ressourcen/faucets.md)); auf Rubicon durch das Bridgen von USDC von Ethereum, Base, Arbitrum, Polygon, Avalanche, Monad oder OP oder von einer Solana-Wallet, mit dem [Rome Bridge](https://bridge-api.mainnet.romeprotocol.xyz/). Deploye auf Rubicon mit denselben Artefakten, die du auf Hadrian getestet hast — nur die Chain-ID und die Wrapper-Adressen unterscheiden sich.

## Hardhat

### Setup

```bash
mkdir my-rome-project && cd my-rome-project
npx hardhat --init
```

Übernimm die Standardwerte (Hardhat 3, aktuelles Verzeichnis, TypeScript + viem-Vorlage); Abhängigkeiten werden automatisch installiert.

### hardhat.config.ts

```typescript
import hardhatToolboxViemPlugin from "@nomicfoundation/hardhat-toolbox-viem";
import { configVariable, defineConfig } from "hardhat/config";

export default defineConfig({
  plugins: [hardhatToolboxViemPlugin],
  solidity: {
    profiles: {
      default: { version: "0.8.28" },
      production: {
        version: "0.8.28",
        settings: { optimizer: { enabled: true, runs: 200 } },
      },
    },
  },
  networks: {
    hadrian: {
      type: "http",
      chainType: "l1",
      chainId: 200010,
      url: "https://hadrian.testnet.romeprotocol.xyz/",
      accounts: [configVariable("PRIVATE_KEY")],
    },
    rubicon: {
      type: "http",
      chainType: "l1",
      chainId: 7531,
      url: "https://rubicon.mainnet.romeprotocol.xyz/",
      accounts: [configVariable("PRIVATE_KEY")],
    },
  },
});
```

`configVariable("PRIVATE_KEY")` wird aus der Umgebung aufgelöst (oder dem verschlüsselten Keystore — `npx hardhat keystore set PRIVATE_KEY`).

### Bereitstellen

```bash
npx hardhat run scripts/deploy.ts --network hadrian
```

### Auf dem Block-Explorer verifizieren

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

Benötigt die Sourcify-Verifier-Konfiguration aus [Verträge verifizieren](https://docs.rome.builders/de/entwicklerleitfaden/verify-contracts.md) in deinem `hardhat.config.ts`.

## Foundry

### Setup

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

### Bereitstellen

```bash
# Testnetz
forge create --rpc-url https://hadrian.testnet.romeprotocol.xyz/ \

  --private-key $PRIVATE_KEY \

  src/Counter.sol:Counter
```

### Bereitgestellten Vertrag aufrufen

```bash
# Lesen
cast call 0xCONTRACT_ADDRESS "number()" \

  --rpc-url https://hadrian.testnet.romeprotocol.xyz/

# Schreiben
cast send 0xCONTRACT_ADDRESS "increment()" \

  --rpc-url https://hadrian.testnet.romeprotocol.xyz/ \

  --private-key $PRIVATE_KEY
```

## Mit dem Rome Solidity SDK

Für Verträge, die mit Solana-Programmen interagieren, verwende die Schnittstellen aus dem öffentlichen [`rome-solidity`](https://github.com/rome-protocol/rome-solidity) Repository. Es wird von GitHub installiert, nicht von npm:

```bash
# Hardhat / npm
npm install github:rome-protocol/rome-solidity

# Foundry
forge install rome-protocol/rome-solidity
# dann in foundry.toml, unter [profile.default]:
# remappings = ["@rome-protocol/rome-solidity/=lib/rome-solidity/"]
```

Verträge jenseits von `interface.sol` und die Orakel-Schnittstellen (zum Beispiel die ERC-20-Wrapper und die Factory) importieren OpenZeppelin. Mit npm kommt es als Abhängigkeit mit. Mit Foundry führe außerdem aus `forge install OpenZeppelin/openzeppelin-contracts` und füge die Zuordnung hinzu `@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/`.

Mit npm wird das Paket als `@rome-protocol/rome-solidity`, sodass der folgende Import aus `node_modules`. Mit Foundry sorgt die Zuordnung dafür, dass derselbe Import aus `lib/rome-solidity`.

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

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

contract MyRomeContract {
    IHelperProgram constant Helper =
        IHelperProgram(0xFF00000000000000000000000000000000000009);
    ICrossProgramInvocation constant Cpi =
        ICrossProgramInvocation(0xFF00000000000000000000000000000000000008);

    // Übertrage ein SPL-Token aus der PDA des Aufrufers
    function moveSpl(address to, uint64 tokens, bytes32 mint) external {
        Helper.transfer_spl(to, tokens, mint);
    }

    // Beliebiges Solana-Programm per CPI aufrufen
    function callSolanaProgram(
        bytes32 programId,
        ICrossProgramInvocation.AccountMeta[] calldata accounts,
        bytes calldata data
    ) external {
        Cpi.invoke(programId, accounts, data);
    }
}
```

## Bringe ein bestehendes Protokoll mit

Jeder Solidity-Contract lässt sich auf Rome unverändert deployen — ein Compliance-Contract, ein DeFi-Protokoll oder eine bestehende gehärtete Anwendung. Das eine, was in deinem Contract nicht enthalten ist, ist die **einmalige Wrapper-Genehmigung**: ein Nutzer, der SPL-Wrapper-Token (wUSDC und ähnliche) über deinen Contract bewegt, muss dem Wrapper dieses Tokens einmalig das Recht geben, seine Tokens vor dem ersten `transferFrom`. Ohne sie schlägt die Übertragung mit dem SPL-Fehler `0x4`. Prüfe `isEnabled(user)` auf dem Wrapper fehl und siehe [muss, dass jeder Nutzer dies getan hat. Siehe](https://docs.rome.builders/de/kernkonzepte/token-interop.md#one-time-grant-per-wallet); dein Frontend sendet die Genehmigung, dein Contract ändert sich nicht. Zwei Produktionsbeispiele, die du mit demselben Hardhat-/Foundry-Flow oben forken und deployen kannst:

* [**compound-on-rome-comet**](https://github.com/rome-protocol/compound-on-rome-comet) — kanonisches Compound v3 (Comet), Standard-Foundry.
* [**rome-aave-v3**](https://github.com/rome-protocol/rome-aave-v3) — kanonisches Aave v3.

Beide erhalten Solana-Ausführung und CPI-Komposierbarkeit ohne Änderungen am Contract; ihre Nutzer erteilen die oben beschriebene einmalige Wrapper-Genehmigung vor der ersten Einzahlung.

## Gas

Lass dein Tooling Gas schätzen (`eth_estimateGas`; Hardhat, `forge create` und `cast` alle tun das) und hardcodiere niemals `21000`. Auf Rome entstehen die meisten Kosten eines Schreibvorgangs durch das Erstellen von Solana-Konten, etwa eines deployten Contracts, eines neuen Token-Kontos oder eines noch nie verwendeten Empfängers, und die Schätzung enthält sie. Bei einem Aufruf, der Solana-CPIs ausführt, kann die Schätzung zu niedrig ausfallen, also halte einen Puffer ein. Rome berechnet das tatsächlich verwendete Gas. Gemessen auf Hadrian: Das Bereitstellen eines 10-Byte-Contracts wurde mit 1.147.921 Gas geschätzt und verbraucht, und eine native Überweisung an eine bestehende Adresse wurde mit 21.000 geschätzt und mit 10.001 verbraucht. Ein echter Contract kostet mehr, also schätze deinen eigenen Deploy. Die [JSON-RPC-Seite](https://docs.rome.builders/de/referenz/json-rpc.md#gas-is-solana-derived-estimate-dont-hardcode) enthält die gemessene Tabelle.

## Bereitstellungsbeschränkungen

| Beschränkung            | Limit                  | Hinweise                                                          |
| ----------------------- | ---------------------- | ----------------------------------------------------------------- |
| Maximale Vertragsgröße  | 24 KB                  | Wie bei Ethereum (EIP-170, 24.576 Bytes)                          |
| Transaktionsgrößenlimit | 80 KB pro Holder       | Große Deployments werden transparent auf Holder-Konten aufgeteilt |
| Compute-Budget          | \~1,4 Mio. CU (atomar) | Nutze den iterativen Modus für schwere Verträge                   |
| Solidity-Version        | 0.8.28 empfohlen       | Frühere Versionen funktionieren, aber 0.8.28 passt zum SDK        |

## Häufige Fehler

| Fehler                                                                                  | Ursache                                                                                         | Behebung                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `unzureichende Mittel für Gas`                                                          | EVM-Adresse hat kein Gas-Token                                                                  | Hadrian: bridge Test-USDC mit dem [Rome Bridge](https://docs.rome.builders/de/apps-auf-rome/bridge-api.md) (siehe [Schnellstart](https://docs.rome.builders/de/erste-schritte-1/quickstart.md), Schritt 2); Rubicon: bridge echtes USDC mit dem [Rome Bridge auf dem Mainnet](https://bridge-api.mainnet.romeprotocol.xyz/) |
| `Nonce zu niedrig`                                                                      | Veralteter Nonce in der Wallet                                                                  | Setze das MetaMask-Konto zurück oder gib den Nonce manuell an                                                                                                                                                                                                                                                               |
| `Ausführung rückgängig gemacht`                                                         | Contract-Logik fehlgeschlagen                                                                   | Debugge mit `eth_call` oder `forge test --fork-url`                                                                                                                                                                                                                                                                         |
| `Ausführung rückgängig gemacht` mit SPL-Fehler `0x4` beim Verschieben von Wrapper-Token | Der Nutzer hat die einmalige Wrapper-Genehmigung nicht erteilt                                  | Prüfe `isEnabled(user)` auf dem Wrapper und sende `approve_spl` einmal ([Details](https://docs.rome.builders/de/kernkonzepte/token-interop.md#one-time-grant-per-wallet))                                                                                                                                                   |
| `Transaktion zu niedrig bepreist`                                                       | Gaspreis unter dem Minimum                                                                      | Erhöhe den Gaspreis in der Transaktion                                                                                                                                                                                                                                                                                      |
| Eine Überweisung oder ein Deploy schlägt mit einem festen Gaslimit fehl                 | Ein hart codiertes Limit wie `21000` liegt unter den Kosten für das Erstellen der Solana-Konten | Entferne es und verwende `eth_estimateGas`                                                                                                                                                                                                                                                                                  |

## Wie es weitergeht

* [Öffne deinen Contract für Solana-Nutzer](https://docs.rome.builders/de/entwicklerleitfaden/open-to-solana-users.md) — lasse Nutzer der Solana-Wallet das ausführen, was du gerade deployt hast
* [Solana aus EVM aufrufen](https://docs.rome.builders/de/entwicklerleitfaden/call-solana-from-evm.md) — verwende CPI-Precompiles, um mit Solana-Programmen zu interagieren
* [Verträge verifizieren](https://docs.rome.builders/de/entwicklerleitfaden/verify-contracts.md) — veröffentliche deinen Quellcode im Block-Explorer


---

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