Skip to content

Add wallet transaction simulation before on-chain submission #609

Description

@Smartdevs17

Context

On-chain Soroban transactions (subscription charges, credit transfers, SLA claims) can fail due to insufficient gas, contract state, or auth errors, wasting fees and causing poor UX.

Current Limitation/Problem

Transactions are submitted without simulation. Users pay fees for failed transactions and get cryptic error messages.

Expected Outcome

Pre-submission transaction simulation using Soroban simulation API: validate gas, auth requirements, predicted state changes, and expected results before wallet signature.

Acceptance Criteria

  • Simulation endpoint: POST /transactions/simulate returns gas estimate, auth entries, state diff, expected result
  • Mobile integration: show simulation result in bottom sheet before wallet signature request (XRPL or Freighter)
  • Gas estimation: accurate to within 10% of actual consumption (measured against 100 historical transactions)
  • Failure prediction: detect common errors (insufficient balance, expired entry, auth mismatch, contract error) before submission
  • Fallthrough: if simulation service unavailable (offline), warn user and skip simulation
  • Metrics: simulation success rate, gas accuracy percentage, prediction accuracy (false positive/negative)
  • Edge case: simulation succeeds but transaction fails (state changed between simulate and submit)

Technical Scope

  • backend/simulation/ - new domain module
  • backend/simulation/connectors/ - Soroban RPC simulation client
  • mobile/app/services/ - TransactionSimulationService
  • mobile/app/components/ - SimulationResultSheet (bottom sheet component)
  • contracts/simulation/ - helper contract for dry-run state access

Metadata

Metadata

Assignees

Labels

200-points200 point issueStellar WaveIssues in the Stellar wave programdrips-waveIssues in the Drips Wave programhighHigh complexity issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions