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
Frontend state integration
For the Redux adapter, installation, UI wiring, and account restoration, follow Frontend integration.Persistence strategies
When saving and restoring SDK state:- Scope by wallet owner — hydrate SDK state when the user connects an 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
Examples
Explore frontend and backend reference applications.
State methods
Where production state data originates.
Operation lifecycle
When prepare reads and execute writes state.
Setup
Connect React and Redux to your account and transaction flow.