> 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/almntjat/rome-sdk.md).

# Rome SDK

توفر Rome SDK واجهات Solidity مُنَمْذَجة للتفاعل مع برامج Solana من عقود EVM الذكية. إنها مجموعة أدوات المطورين لبناء تطبيقات متعددة بيئات التشغيل على Rome.

## مجموعات SDK

لدى Rome مجموعات SDK لثلاث فئات — مطورو التطبيقات (TypeScript)، ومطورو العقود (Solidity)، ومشغلو البنية التحتية (Rust).

### TypeScript SDK (`@rome-protocol/sdk`)

**لمطوري dapp والواجهة الأمامية** — مجموعة SDK التي يبدأ بها معظم منشئي التطبيقات. [`@rome-protocol/sdk`](https://github.com/rome-protocol/rome-sdk-ts) تغلف مسار الكتابة في Rome بحيث يرسل تطبيق ويب معاملات Rome بشكل صحيح: `submitRomeTx` (مسار الكتابة الصحيح بالإضافة إلى معالجة الغاز/الرسوم)، اشتقاق PDA / ATA، CPI `invoke` / `invoke_signed` المشفِّرات، وروابط precompile، و `/bridge` المسار الفرعي. التثبيت من المستودع أولاً (النشر على npm قيد الانتظار):

```bash
npm install github:rome-protocol/rome-sdk-ts#v0.2.1
```

```typescript
import { submitRomeTx } from '@rome-protocol/sdk';
// أرسل أي كتابة EVM عبر Rome من خلال مسار الكتابة الصحيح (يتعامل مع ترميز الغاز/الرسوم).
```

العينات المرجعية العامة — [rome-dex](https://github.com/rome-protocol/rome-dex) و [cardo](https://github.com/rome-protocol/cardo) — تستهلك هذه المجموعة SDK.

**المساران، مجموعة SDK واحدة.** `submitRomeTx` هو مسار EVM (MetaMask). أمّا بالنسبة إلى **مسار Solana** — محفظة Phantom/Solana تدير تطبيق EVM الخاص بك — `submitRomeTxSolanaLane` يعكسه: يوقّع المستخدم معاملة Solana وتقوم Rome بتنفيذها كمعاملة EVM من هويته المشتقة، من دون مفتاح EVM. تنتقل القيمة إلى الداخل والخارج عبر `buildFundLeg` / `buildSweepLeg` بوصفه غلاف ERC-20 (مثل `wUSDC`), وليس msg.value الأصلي `msg.value` — لا يحتفظ المرسل الاصطناعي بأي شيء في حالة السكون — ويتم توفير مرسل اصطناعي أول مرة تلقائيًا عند أول استخدام. انظر [ابنِ تطبيقًا ثنائي المسارين](/ar/adlh-almtwr/dual-lane-app.md) و [استدعِ EVM من Solana](/ar/adlh-almtwr/call-evm-from-solana.md).

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

**لمطوري Solidity.** يوفّر واجهات precompile، وأغلفة ERC-20/SPL، واشتقاق PDA، وأدوات CPI. نشر npm قيد الانتظار؛ حاليًا تستخدم هذه من [`rome-solidity`](https://github.com/rome-protocol/rome-solidity) المستودع العام (اعتماد git أو ملفات منسوخة).

```solidity
import {ISystemProgram, ICrossProgramInvocation, IHelperProgram, IWithdraw}
    from "@rome-protocol/rome-solidity/contracts/interface.sol";
import {SPL_ERC20} from "@rome-protocol/rome-solidity/contracts/erc20spl/erc20spl.sol";
import {RomeEVMAccount} from "@rome-protocol/rome-solidity/contracts/rome_evm_account.sol";
```

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

**لمشغلي البنية التحتية.** مساحة عمل Rust تتعامل مع تركيب المعاملات، والتفاعل مع Solana، وتسعير الغاز، وفهرسة الكتل. تُستخدم بواسطة Proxy وHercules.

## Solidity SDK: ما المضمن

### واجهات Precompile

اربط واجهة بعنوان precompile الخاص بها:

```solidity
ISystemProgram          constant System   = ISystemProgram(0xFF00000000000000000000000000000000000007);
ICrossProgramInvocation constant Cpi      = ICrossProgramInvocation(0xFF00000000000000000000000000000000000008);
IHelperProgram          constant Helper   = IHelperProgram(0xFF00000000000000000000000000000000000009);
IWithdraw               constant Withdraw = IWithdraw(0x4200000000000000000000000000000000000016);
// المسار المخزن مؤقتًا: ISplCached 0xff…05, IAssociatedSplCached 0xff…06, ISystemCached 0xff…04, IWithdrawCached 0xff…0b
```

### عمليات رموز SPL

استخدم `IHelperProgram` (`0xff…09`) للأوليات SPL الموقعة بواسطة مستخدم-PDA:

```solidity
// أنشئ ATA الخاص بالمتصل لعملة mint
Helper.create_ata(user, mint);

// انقل SPL من PDA الخاص بالمتصل
Helper.transfer_spl(to, tokens, mint);
```

في المسار المخزن مؤقتًا، توجد العمليات المكافئة على `ISplCached` (`0xff…05`) و `IAssociatedSplCached` (`0xff…06`). انظر `interface.sol` لجميع الأشكال الزائدة؛ يستخدم العقد مسارًا واحدًا بشكل متسق.

### اشتقاق PDA

```solidity
// اشتق PDA الخاص بمستخدم Solana
bytes32 userPda = RomeEVMAccount.pda(msg.sender);

// اشتق PDA مع salt (لإنشاء عدة PDAs لكل مستخدم)
bytes32 pda = RomeEVMAccount.pda_with_salt(msg.sender, salt);

// ابحث عن PDA عشوائي
(bytes32 pda, uint8 bump) = SystemProgram.find_program_address(programId, seeds);
```

### الاستدعاء عبر البرامج

```solidity
// استدعِ أي برنامج Solana
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);

// استدعِ مع توقيع PDA
CpiProgram.invoke_signed(programId, accounts, data, seeds);

// اقرأ بيانات الحساب
(uint64 lamports, bytes32 owner, bool isSigner, bool isWritable, bool executable, bytes memory data)
    = CpiProgram.account_info(pubkey);
```

### ERC-20 فوق رموز SPL

```solidity
// انشر غلافًا لأي mint من SPL
ERC20SPLFactory factory = ERC20SPLFactory(FACTORY_ADDRESS);
address wrapper = factory.add_spl_token_with_metadata(splMint);

// استخدم الغلاف كـ ERC-20 قياسي
SPL_ERC20 token = SPL_ERC20(wrapper);
token.transfer(recipient, amount);
uint256 balance = token.balanceOf(user);
```

### فك ترميز Borsh

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

// حلّل بيانات حساب Solana (صيغة Borsh ذات ترتيب little-endian)
(uint64 value, uint256 newOffset) = Convert.read_u64le(data, offset);
(bytes32 pubkey, uint256 newOffset2) = Convert.read_bytes32(data, offset);
```

### بيانات Metaplex الوصفية

```solidity
import {MplTokenMetadataLib} from "@rome-protocol/rome-solidity/contracts/mpl_token_metadata/lib.sol";

// حمّل بيانات الرمز المميّزة الوصفية من Metaplex
MplTokenMetadataLib.Metadata memory meta = MplTokenMetadataLib.load_metadata(
    mintPubkey, mplProgramId, cpiAddress
);
string memory name = meta.name;
string memory symbol = meta.symbol;
```

## Rust SDK: البنية

Rust SDK هو مساحة عمل Cargo. حِزَمه الأساسية:

| الحزمة              | الغرض                                                                                                         |
| ------------------- | ------------------------------------------------------------------------------------------------------------- |
| `rome-sdk`          | واجهة برمجة التطبيقات الأساسية: `Rome` بنية struct، والإعدادات، وأنواع المعاملات (RheaTx, RemusTx, RomulusTx) |
| `rome-evm-client`   | عميل rollup لـ EVM، وTxBuilder، وResourceFactory، وتكامل المحاكي                                              |
| `rome-solana`       | برج Solana، وعميل RPC، وتجزئة المعاملات وتتبعها                                                               |
| `rome-utils`        | أدوات RLP، وhex، وJSON-RPC، والمصادقة                                                                         |
| `rome-obs`          | قابلية المراقبة OpenTelemetry (التتبعات، المقاييس، السجلات)                                                   |
| `rome-meteora`      | مهايئات مجمع Meteora DEX AMM لتسعير الغاز                                                                     |
| `rome-jito-bundler` | منشئ حِزم Jito للإرسال الذري متعدد المعاملات                                                                  |

### أنواع المعاملات

```rust
// معاملة rollup واحدة
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?;

// معاملة ذرية عبر rollup
let remus = RemusTx::new(vec![tx1, tx2]);
let mut tx = rome.compose_cross_rollup_tx(remus).await?;

// معاملة ذرية عبر السلاسل (EVM + Solana)
let romulus = RomulusTx::new(eth_txs, sol_ixs);
let mut tx = rome.compose_cross_chain_tx(romulus, signers).await?;
```

### تجميع الموارد

تجمع SDK أزواج مفاتيح Solana (الدافعين) وفهارس حسابات المحتفظ بها لإرسال المعاملات بالتوازي:

```rust
let resource = resource_factory.get().await?;
let payer = resource.payer();       // زوج مفاتيح Solana
let holder = resource.holder();     // فهرس حساب الحفظ
// تتم إعادة المورد تلقائيًا إلى التجمع عند Drop
```

## خارطة طريق SDK

### مُنشأ ويعمل

* أغلفة رموز SPL وواجهات precompile
* مبادلات Meteora DAMM v1 عبر CPI
* Oracle Gateway V1 + V2 (Pyth Pull, Switchboard V3)
* مساعدات System Program، وفك ترميز Borsh
* ERC20SPL Factory + عقود الجسر

## ما التالي

* [نشر Solidity](/ar/adlh-almtwr/deploy-solidity.md) — انشر عقدك الأول باستخدام SDK
* [استدعِ Solana من EVM](/ar/adlh-almtwr/call-solana-from-evm.md) — استخدم CPI للتفاعل مع برامج Solana
* [عناوين العقود](/ar/almrja/contract-addresses.md) — عناوين عقود SDK المنشورة


---

# 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/almntjat/rome-sdk.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.
