The SDK needs state in both browser applications and Node.js services: private records, wallet-scoped data, pool state, and recipient registry data. Choose a state adapter and a persistence strategy for the runtime where the SDK runs. React and Redux wiring belongs to Frontend integration. Server-side configuration belongs to Backend integration. This page covers the shared state requirements.

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?
If the answer is no, prepare returns status: 'rejected' — often with insufficient_statebefore the wallet signing prompt. After a successful execute, the SDK updates the same cache (consumed records, new outputs, pool snapshot).
SDK state is not a replacement for Redux, Zustand, or your server database. It is a specialized cache for privacy operations. Your UI may mirror subsets of it, but the adapter library is the supported integration boundary.

Choosing a state adapter library

Wire the adapter when creating your network preset client:

In-memory adapter

Pros: zero extra dependencies, fast setup, ideal for Examples. Limits: data is lost when the process ends; not suitable alone for production wallet apps that must survive reload.

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.

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.