Skip to content

feat: add pre-submission Soroban transaction simulation and wallet validation (#609)#637

Open
Auwal007 wants to merge 2 commits into
Smartdevs17:mainfrom
Auwal007:main
Open

feat: add pre-submission Soroban transaction simulation and wallet validation (#609)#637
Auwal007 wants to merge 2 commits into
Smartdevs17:mainfrom
Auwal007:main

Conversation

@Auwal007

Copy link
Copy Markdown

closes #609

Summary

This PR implements end-to-end Soroban transaction simulation before wallet signature requests, addressing issue #609.

The new simulation workflow validates transactions prior to on-chain submission, allowing users to detect failures early, review expected execution outcomes, and receive accurate gas estimates before signing with Freighter or XRPL wallets.

By simulating transactions ahead of submission, the application reduces failed on-chain transactions, prevents unnecessary fee consumption, and significantly improves the transaction UX.

Changes Included

Backend

  • Added a new transaction simulation domain under backend/simulation/.

  • Implemented Soroban RPC simulation client integration.

  • Added support for pre-submission transaction simulation.

  • Exposed simulation functionality through backend services.

  • Added standardized simulation DTOs and error handling.

  • Implemented metrics collection for:

    • Simulation success rate
    • Gas estimation accuracy
    • Prediction accuracy

Mobile

  • Added TransactionSimulationService for interacting with the simulation backend.
  • Implemented SimulationResultSheet to display simulation details before wallet signature requests.
  • Integrated simulation into the existing crypto payment flow.
  • Added offline fallback behavior when simulation services are unavailable.

Transaction Validation

  • Added prediction for common transaction failures, including:

    • Insufficient balance
    • Authorization mismatch
    • Expired ledger entries
    • Contract execution errors
    • Invalid transaction state

Contracts

  • Added helper simulation contract utilities for safe dry-run state inspection and state diff generation.

Reliability Improvements

  • Added handling for state drift scenarios where simulation succeeds but on-chain submission fails due to ledger state changes.
  • Separated shared simulation types into shared/types/simulation to avoid frontend/backend dependency issues and Metro bundler failures.

User Flow

Build unsigned transaction
→ Simulate transaction
→ Display simulation results
→ User confirms
→ Request wallet signature
→ Submit transaction

Benefits

  • Prevents users from signing transactions that are likely to fail.
  • Reduces unnecessary on-chain fees.
  • Improves transparency around gas costs and execution outcomes.
  • Enhances overall wallet and transaction UX.

Closes #609.

Auwal007 and others added 2 commits June 24, 2026 08:07
This commit introduces a new transaction simulation layer for Soroban transactions that operates prior to on-chain submission.

- Created `backend/simulation` to process `simulateTransaction` calls to Soroban RPC.
- Extracted shared DTOs to `shared/types/simulation` to avoid circular dependency and frontend crashes.
- Created `TransactionSimulationService` on the mobile frontend to dispatch simulation requests and handle the `state drift` edge-case.
- Added `SimulationResultSheet` component to display gas fees, expected results, and potential errors before transaction signing.
- Added unit tests for backend simulation service and fixed the gas benchmark script to output accurate values.
- Integrated `SimulationResultSheet` to `CryptoPaymentScreen`.
- Added a `contracts/simulation` module with read-only test functions.
Add wallet transaction simulation before on-chain submission
@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Auwal007 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

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.

Add wallet transaction simulation before on-chain submission

1 participant