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

# نشر عقود Solidity

يغطي هذا الدليل نشر عقود Solidity الذكية على Rome EVM باستخدام Hardhat وFoundry.

## المتطلبات المسبقة

* Node.js v22.13+ (Hardhat) أو Foundry مثبتان
* عنوان Rome EVM ممول (انظر [البداية السريعة](/ar/albda/quickstart.md))
* مفتاحك الخاص مُصدَّر كمتغير بيئي

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

## إعداد الشبكة

| الشبكة                  | رابط RPC                                    | معرّف السلسلة |
| ----------------------- | ------------------------------------------- | ------------- |
| محلية                   | `http://localhost:9090`                     | `1001`        |
| هادريان (شبكة التطوير)  | `https://hadrian.testnet.romeprotocol.xyz/` | `200010`      |
| مارتيوس (شبكة الاختبار) | `https://martius.testnet.romeprotocol.xyz/` | `121214`      |

## Hardhat

### الإعداد

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

اقبل الإعدادات الافتراضية (Hardhat 3، الدليل الحالي، قالب TypeScript + viem)؛ سيتم تثبيت الاعتمادات تلقائيًا.

### 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: {
    rome_local: {
      type: "http",
      chainType: "l1",
      chainId: 1001,
      url: "http://localhost:9090",
      accounts: [configVariable("PRIVATE_KEY")],
    },
    hadrian: {
      type: "http",
      chainType: "l1",
      chainId: 200010,
      url: "https://hadrian.testnet.romeprotocol.xyz/",
      accounts: [configVariable("PRIVATE_KEY")],
    },
    martius: {
      type: "http",
      chainType: "l1",
      chainId: 121214,
      url: "https://martius.testnet.romeprotocol.xyz/",
      accounts: [configVariable("PRIVATE_KEY")],
    },
  },
});
```

`configVariable("PRIVATE_KEY")` يتم حله من البيئة (أو من مخزن المفاتيح المشفّر — `npx hardhat keystore set PRIVATE_KEY`).

### النشر

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

### التحقق على مستكشف الكتل

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

يحتاج إلى إعداد المدقق Sourcify من [التحقق من العقود](/ar/adlh-almtwryn/verify-contracts.md) في `hardhat.config.ts`.

## Foundry

### الإعداد

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

### النشر

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

# شبكة التطوير
forge create --rpc-url https://hadrian.testnet.romeprotocol.xyz/ \
  --private-key $PRIVATE_KEY \
  src/Counter.sol:Counter
```

### استدعاء العقد المنشور

```bash
# قراءة
cast call 0xCONTRACT_ADDRESS "number()" \
  --rpc-url https://hadrian.testnet.romeprotocol.xyz/

# كتابة
cast send 0xCONTRACT_ADDRESS "increment()" \
  --rpc-url https://hadrian.testnet.romeprotocol.xyz/ \
  --private-key $PRIVATE_KEY
```

## استخدام Rome Solidity SDK

للعقود التي تتفاعل مع برامج Solana، استخدم الواجهات من المستودع العام [`rome-solidity`](https://github.com/rome-protocol/rome-solidity)  (النشر عبر npm قيد الانتظار):

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

    // نقل رمز SPL مميز من PDA الخاص بالمتصل
    function moveSpl(address to, uint64 tokens, bytes32 mint) external {
        Helper.transfer_spl(to, tokens, mint);
    }

    // استدعاء أي برنامج Solana عبر CPI
    function callSolanaProgram(
        bytes32 programId,
        ICrossProgramInvocation.AccountMeta[] calldata accounts,
        bytes calldata data
    ) external {
        Cpi.invoke(programId, accounts, data);
    }
}
```

## شغّل بروتوكولًا قائمًا

أي عقد Solidity يُنشر على Rome دون تعديل — عقد امتثال، أو بروتوكول DeFi، أو تطبيق مُحصَّن قائم. يوجد مثالان للإنتاج يمكنك نسخهما ونشرهما باستخدام نفس مسار Hardhat / Foundry أعلاه:

* [**compound-on-rome-comet**](https://github.com/rome-protocol/compound-on-rome-comet) — الإصدار المرجعي من Compound v3 (Comet)، باستخدام Foundry القياسي.
* [**rome-aave-v3**](https://github.com/rome-protocol/rome-aave-v3) — الإصدار المرجعي من Aave v3.

كلاهما يكتسب تنفيذ Solana وقابلية التركيب عبر CPI دون أي تغييرات على العقد.

## قيود النشر

| القيد                  | الحد                 | ملاحظات                                                  |
| ---------------------- | -------------------- | -------------------------------------------------------- |
| الحد الأقصى لحجم العقد | 24 KB                | مثل Ethereum تمامًا (EIP-170، 24,576 بايت)               |
| حد حجم المعاملة        | 80 KB لكل حامل       | يتم تقسيم عمليات النشر الكبيرة عبر حسابات الحامل بشفافية |
| ميزانية الحوسبة        | حوالي 1.4M CU (ذرية) | استخدم الوضع التكراري للعقود الثقيلة                     |
| إصدار Solidity         | يوصى بالإصدار 0.8.28 | تعمل الإصدارات الأقدم، لكن 0.8.28 يطابق SDK              |

## الأخطاء الشائعة

| الخطأ                        | السبب                          | الإصلاح                                                                                                                 |
| ---------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `insufficient funds for gas` | عنوان EVM لا يحتوي على رمز غاز | قم بتغليف الغاز عبر [تطبيق Rome](https://app.devnet.romeprotocol.xyz) (انظر [البداية السريعة](/ar/albda/quickstart.md)) |
| `nonce too low`              | nonce قديم في المحفظة          | أعد تعيين حساب MetaMask أو حدّد nonce يدويًا                                                                            |
| `execution reverted`         | فشل منطق العقد                 | استكشف باستخدام `eth_call` أو `forge test --fork-url`                                                                   |
| `transaction underpriced`    | سعر الغاز أقل من الحد الأدنى   | ارفع سعر الغاز في المعاملة                                                                                              |

## ما التالي

* [استدعِ Solana من EVM](/ar/adlh-almtwryn/call-solana-from-evm.md) — استخدم precompiles الخاصة بـ CPI للتفاعل مع برامج Solana
* [التحقق من العقود](/ar/adlh-almtwryn/verify-contracts.md) — انشر الشيفرة المصدرية على مستكشف الكتل


---

# 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/ar/adlh-almtwryn/deploy-solidity.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.
