Skip to content

Feat sorobanonchainadaptor#206

Open
RUKAYAT-CODER wants to merge 8 commits intoPulsefy:mainfrom
RUKAYAT-CODER:feat-sorobanonchainadaptor
Open

Feat sorobanonchainadaptor#206
RUKAYAT-CODER wants to merge 8 commits intoPulsefy:mainfrom
RUKAYAT-CODER:feat-sorobanonchainadaptor

Conversation

@RUKAYAT-CODER
Copy link
Copy Markdown

close #203

🚀 Implement SorobanOnchainAdapter for Live Soroban Transactions

📌 Overview

This PR replaces the existing mock on-chain implementation with a production-ready Soroban adapter, enabling real interactions with the AidEscrow smart contract on the Stellar network.

The new SorobanOnchainAdapter integrates with the Stellar network (Testnet/Mainnet) using the Stellar SDK to:

  • Initialize escrow contracts
  • Create claims
  • Disburse funds

This marks a key step toward live blockchain-backed transactions in Wave 3.


🧠 What’s Included

✅ New Feature

  • Production-grade SorobanOnchainAdapter
  • Real Soroban transaction execution via :contentReference[oaicite:0]{index=0}
  • Support for:
    • Escrow initialization
    • Claim creation
    • Fund disbursement

🔄 Adapter Methods Implemented

1. initEscrow

  • Initializes escrow on-chain
  • Submits contract invocation transaction

2. createClaim

  • Creates a claim against an escrow
  • Invokes Soroban contract method

3. disburse

  • Releases funds to beneficiary
  • Handles contract execution and result parsing

⚙️ Blockchain Integration

  • Connects to Stellar Horizon / RPC endpoints
  • Builds Soroban transactions
  • Signs transactions using configured keypair
  • Submits transactions to network
  • Parses XDR responses for execution results

🛠 Implementation Details

📁 New File

  • app/backend/src/onchain/soroban-onchain.adapter.ts

🧩 Core Responsibilities

  • Transaction construction using Stellar SDK
  • Contract invocation handling
  • Error handling for:
    • submission failures
    • contract execution errors
  • XDR decoding for transaction results

🔌 Module Integration

📍 Updated: onchain.module.ts

  • Adapter is now dynamically selected via environment variable:
const adapter =
  process.env.ONCHAIN_ADAPTER === "soroban"
    ? new SorobanOnchainAdapter()
    : new MockOnchainAdapter();

Configuation
ONCHAIN_ADAPTER=soroban
STELLAR_NETWORK=testnet
STELLAR_RPC_URL=https://soroban-testnet.stellar.org
STELLAR_SECRET_KEY=your_secret_key
AID_ESCROW_CONTRACT_ID=your_contract_id

Testing
Local Testing
Uses Soroban CLI for contract deployment and simulation
Integration Testing
Transactions executed against Stellar Testnet
Verified:
Escrow creation
Claim lifecycle
Disbursement flow
 Acceptance Criteria
- [] SorobanOnchainAdapter implemented
- [] Supports initEscrow, createClaim, and disburse
- [] Transactions are built, signed, and submitted via Stellar SDK
- [] Handles transaction errors gracefully
- [] Parses XDR responses correctly
- [] Adapter is selected via ONCHAIN_ADAPTER=soroban
⚠️ Error Handling
- Network failures handled with retries/logging
- Contract execution errors parsed from XDR
- Invalid transaction responses surfaced with clear messages
- 
🚀 Future Improvements
Add retry + backoff strategy for failed transactions
Integrate queue system for async transaction processing
Add transaction status polling
Improve observability (metrics + tracing)
Support multi-signature transactions

📦 Dependencies
@stellar/stellar-sdk

💡 Notes
Current implementation targets Testnet by default
Mainnet support enabled via configuration
Designed for extensibility with additional contract methods

Type of Change
 
 New feature

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 26, 2026

@RUKAYAT-CODER Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER
Copy link
Copy Markdown
Author

Ci fix kindly review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SorobanOnchainAdapter for Live Soroban Transactions

1 participant