Status: Accepted Date: 2026-03-28 Authors: StellarGuard Team
StellarGuard submits Soroban transactions for treasury operations (deposits, withdrawals) and governance actions (proposal creation, voting). Each transaction passes through multiple stages: simulation, signing via Freighter, submission, and confirmation polling. Users need visibility into which stage is active and clear error reporting when a stage fails.
Implement a transaction lifecycle model with the useTxLifecycle hook:
- Step-based state machine: Transactions progress through
idle -> simulating -> signing -> submitting -> polling -> success | errorstates. - Freighter signing: Transaction XDR is passed to
signTransactionfrom@stellar/freighter-api. The signed XDR is then submitted to Soroban RPC. - Polling via sorobanClient: After submission,
sorobanClient.pollTransactionhandles confirmation with configurable timeout and interval. - Error model: Errors are classified by stage (
simulation_failed,user_rejected,submission_failed,timeout) so the UI can display stage-specific guidance. - Toast integration:
react-hot-toastprovides user feedback for success and failure states.
- Users always know the current transaction stage
- Stage-specific errors enable targeted recovery guidance
- The lifecycle hook is reusable across all transaction types
- The step model adds complexity compared to a simple submit-and-wait approach
- Polling timeout must be tuned per network (testnet vs mainnet block times)
- The error classification schema may need extension as new transaction types are added
- Fire-and-forget submission: Rejected because users need confirmation feedback, and Soroban transactions require polling for finality.
- WebSocket subscription for confirmation: Not available on Soroban RPC; polling is the only option.