Skip to content

Implement transaction lifecycle (simulate, build, sign, submit) #55

@Otaiki1

Description

@Otaiki1

Context

Every write (create raffle, buy ticket, refund) follows: simulate tx → estimate fee → build XDR → request wallet signature → submit → poll confirmation. Centralize this in the SDK so modules don't duplicate logic.

Goal

  • Implement a shared flow (e.g. in ContractService or a TxLifecycleService): given a built transaction, (1) simulate to get result and fee; (2) set fee (and optional resource fees); (3) get signature from WalletAdapter; (4) submit to RPC; (5) poll until confirmed or timeout.
  • Return tx hash and optionally ledger; throw or return error on simulation failure, user reject, or submission failure.

Contributor guide

  1. Directory: sdk/
  2. In contract.service.ts or a new tx-lifecycle.service.ts: implement simulate(), then build final tx with fee, call wallet.signTransaction(xdr), then submit and poll getTransaction until success/failure.
  3. Use Stellar SDK for simulation and submission; handle Soroban-specific response format.
  4. Raffle and ticket services should use this for every write; read-only calls can use simulate without signing.

References

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions