Open financial rails for Stellar.
luminarail-contracts contains the Soroban smart contracts written in Rust for LuminaRail's cross-border settlement infrastructure on the Stellar network.
Caution
TESTNET DEVELOPMENT CONTRACTS: These smart contracts are designed strictly for Stellar Testnet development, testing, and simulation. They must NOT be treated as production-ready mainnet custody infrastructure or deployed to Mainnet without comprehensive security audits.
LuminaRail is organized across three modular open-source repositories:
luminarail-contracts(This repository): Soroban smart contracts written in Rust (escrow,settlement_vault,fee_manager).luminarail-backend: Express / Node.js API service handling FX rates, order state machines, Paystack webhooks, and Soroban transaction submission.luminarail-frontend: Next.js 16 UI application for merchants, dashboard analytics, order tracking, and wallet integration.
| Subsystem / Integration | Sandbox / Development Status | Production Requirement |
|---|---|---|
| Network Ledger | Stellar Testnet (Soroban RPC & Horizon RPC) | Independent Mainnet security audit & deployment |
| Token Asset Contract | Testnet Mock USDC Stellar Asset Contract | Official Circle Mainnet USDC Asset Contract (GA5ZSEJYB37JRC5AVCIA5XYGEVYWM3D3THC7WUXDVXD4TXMKT626B6AC) |
| Contract Administration | Single Admin key in test environment | Multi-signature Gnosis / Soroban admin vault |
| Storage TTL | Bumped manually / during test iterations | Automated cron worker for TTL bumping |
luminarail-contracts provides on-chain financial primitives implemented as Soroban smart contracts. It manages multi-party conditional escrows, coordinates on-chain settlement executions, and calculates protocol service fees on the Stellar Testnet.
Off-chain cross-border settlements often rely on centralized single-party escrow services, exposing users to counterparty risk, lack of transaction proof, and opaque fee calculation logic. luminarail-contracts provides:
- Trustless Settlement Coordination: Smart contracts enforce state machine transitions on-chain.
- Cryptographic Authorization: Standardized Soroban
require_auth()checks ensure only authorized depositors, admins, or release authorities can invoke state changes. - Capped Protocol Fees: Protocol fee calculations enforce strict BPS rules and checked arithmetic to eliminate overflow vulnerability risks.
luminarail-contracts acts as the decentralized settlement layer for LuminaRail. The backend engine (luminarail-backend) submits transaction invocations to these contracts, which execute on the Stellar blockchain ledger.
Rust developers with experience in smart contracts, WebAssembly (Wasm), Soroban SDK, cryptography, or security auditing are invited to contribute.
The repository is structured as a Cargo workspace with three primary smart contracts:
contracts/
├── escrow/ # Multi-party conditional escrow contract
├── settlement_vault/ # On-chain settlement coordination primitive
└── fee_manager/ # Protocol fee calculation & BPS bounds manager
- State Machine:
Created(0) →Funded(1) →Released(2) - Authorization Enforcement:
depositor.require_auth()required for escrow creation and funding.release_authority.require_auth()required to release locked funds to the beneficiary.
- Storage: Persistent storage keyed by
DataKey::Escrow(escrow_id). - Token Integration: Interacts with Stellar Asset contracts using the standard
token::ClientSoroban interface.
- State Machine:
Pending(0) →Executed(1) - Authorization Enforcement:
initialize()ensures one-time initialization of the contract administrator.admin.require_auth()required for settlement creation.- Both
adminandsourceauthorize token transfer execution (source.require_auth()).
- Storage: Instance storage for
Admin; Persistent storage keyed byDataKey::Settlement(settlement_id). - Safety Checks: Double-execution protection and zero-amount transfer rejection.
- Basis Points (BPS) Calculation: Fee calculated as
(amount * basis_points) / 10,000. - Strict Caps: Enforces
MAX_FEE_BPS = 1000(capped at 10.00%). BPS updates requireadmin.require_auth(). - Arithmetic Safety: Uses Rust
checked_mulandchecked_divto protect against integer overflows. - Storage: Instance storage for
AdminandFeeBps.
Backend Settlement Engine (luminarail-backend)
│
▼ (Soroban RPC / Transaction Submission)
│
┌──────────────┴──────────────────────────────────────┐
│ Soroban Smart Contracts │
│ │
│ ┌────────────────────┐ ┌─────────────────────┐ │
│ │ SettlementVault │ │ FeeManager │ │
│ │ (Pending→Executed)│ │ (Capped 1000 BPS) │ │
│ └─────────┬──────────┘ └─────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────┐ │
│ │ Escrow Contract │ │
│ │ (Created→Funded→ │ │
│ │ Released) │ │
│ └────────────────────┘ │
└─────────────────────────────────────────────────────┘
│
▼
Stellar Ledger State Finality
pub enum DataKey {
Admin, // Instance storage
FeeBps, // Instance storage
Escrow(BytesN<32>), // Persistent storage
Settlement(BytesN<32>), // Persistent storage
}The LuminaRail backend interacts with contracts through Soroban RPC and @stellar/stellar-sdk:
Order (SETTLEMENT_PENDING)
│
▼
Backend Settlement Engine (SettlementWorker)
│
▼
Soroban RPC Simulation & Submission
│
▼
Soroban Contract Invocation (create_settlement)
│
▼
Stellar Ledger Finality Confirmation
│
▼
Order Status (COMPLETED)
- Language: Rust 1.80+ (2021 Edition)
- Compilation Target:
wasm32-unknown-unknown - SDK: Soroban SDK
22.0.1 - Crypto Library:
ed25519-dalek2.2.0
- Rust 1.80 or higher
wasm32-unknown-unknowntarget installed via Rustup
-
Add Wasm Target:
rustup target add wasm32-unknown-unknown
-
Verify Code Formatting:
cargo fmt --check
-
Run Clippy Linter:
cargo clippy --all-targets --all-features -- -D warnings
-
Compile Workspace Contracts:
cargo check
-
Build WebAssembly Binaries:
cargo build --target wasm32-unknown-unknown --release
The workspace includes 15 unit tests across the three contracts, testing happy-path lifecycles, duplicate ID rejections, authorization boundaries, zero-amount handling, and arithmetic overflow protection.
# Run all Soroban unit tests
cargo testcontracts/escrow: 5 unit tests verifying lifecycle, double-funding rejection, double-release rejection, zero-amount rejection, and duplicate ID rejection.contracts/fee_manager: 5 unit tests verifying initialization, BPS fee calculations, max fee cap enforcement, zero-amount calculations, and integer overflow protection.contracts/settlement_vault: 5 unit tests verifying lifecycle, double-initialization rejection, duplicate settlement rejection, zero-amount rejection, and double-execution rejection.
To deploy compiled .wasm contracts to Stellar Testnet using the Soroban CLI:
# 1. Build release Wasm binaries
cargo build --target wasm32-unknown-unknown --release
# 2. Install Soroban CLI (if not installed)
cargo install --locked soroban-cli
# 3. Deploy Wasm bytecodes to Testnet
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/settlement_vault.wasm \
--source-account <signer_identity> \
--network testnet- Fork & Clone the repository.
- Create a Feature Branch:
git checkout -b feature/my-contract-feature - Write Code & Unit Tests: Implement clean Rust code adhering to Soroban best practices.
- Format & Lint: Run
cargo fmt --checkandcargo clippy. - Run Unit Tests: Ensure
cargo testpasses cleanly. - Commit Changes: Commit with descriptive messages (e.g.,
feat(escrow): add event emission). - Open Pull Request: Submit PR against
develop.
- Contract Events: Add structured Soroban event emissions to contract invocations.
- Unit Tests: Add edge-case test coverage for storage TTL extensions.
- Documentation: Improve inline docstrings (
///) for public contract functions. - Soroban CLI Scripts: Add developer helper scripts for testnet deployment and initialization.
Please format bug reports and suggestions clearly:
- Title: Concise description of the issue or improvement.
- Description: Technical details and context.
- Steps to Reproduce: Reproduction details or failing test cases.
- Acceptance Criteria: Clear requirements for completion.
- Private Keys: Never commit secret seed keys (
S...), private keys, or passwords. - Checked Math: Always use checked arithmetic (
checked_add,checked_mul) when computing token amounts or fees. - Authorization: Ensure all state mutations enforce appropriate
.require_auth()checks. - Security Policy: See SECURITY.md for vulnerability disclosure guidelines.
This project is licensed under the MIT License.
- Current Status: Testnet Development Smart Contracts
- Target Network: Stellar Testnet