Why the SDK needs state
During prepare, the SDK reads local domain data to answer: can this operation run right now? Examples:- Does the sender hold a private record with enough balance?
- Is the pool Merkle root current enough to spend selected notes?
- Is the recipient registered (or marked unregistered) in the registry cache?
- Are wallet private-address records and scalars present for signing?
status: 'rejected' — often with insufficient_state — before the wallet signing prompt.
After a successful execute, the SDK updates the same cache (consumed records, new outputs, pool snapshot).
Choosing a state adapter library
Wire the adapter when creating your network preset client:
In-memory adapter (recommended for learning)
Redux adapter (production React)
Use when your Stellar payment UI already runs on Redux Toolkit. The adapter adds an SDK state branch, middleware, and helpers such as hydration from saved JSON. Install:Persistence strategies
When using Redux (or your own persistence layer):- Scope by wallet owner — hydrate SDK state when the user connects a account; clear or swap when they disconnect.
- Serialize bigint amounts as strings in JSON; the SDK normalizes on read.
- Avoid duplicate writers — let the SDK adapter own domain mutations during operations; mirror read-only slices in UI state if needed.
Anti-patterns
- Creating two copies of
transactEnvironment— resolvers registered on one copy are invisible to the other. - Bypassing the adapter library to mutate SDK domain data manually.
- Duplicating private records in app state and SDK state without a clear sync direction — causes loops and stale prepare results.
Related
Quick start (Stellar preset)
In-memory bootstrap walkthrough.
Data sources
Where production state data originates.
Operation lifecycle
When prepare reads and execute writes state.
Setup
Redux adapter and persistence snippet.