Introduction to config
A CurvyConfig is the runtime context used by Curvy actions. It owns service clients, storage, reactive account and network state, proving, note synchronization, and lifecycle resources.
Choose a constructor
| Constructor | Use it for | Defaults |
|---|---|---|
createBrowserCurvyConfig | Browser applications | IndexedDB, session restoration, ambient config |
createServerCurvyConfig | Servers and multi-tenant processes | In-memory storage, no keystore, no ambient config |
createCurvyConfig | Custom runtimes and tests | Explicit control over every adapter |
Explicit config
Pass config to actions in tests, servers, and applications that can host more than one Curvy instance.
const balances = await getBalances({ config });This makes ownership and lifecycle unambiguous and prevents one request from reading another request's ambient state.
Ambient config
Browser constructors register the new config as the ambient default. A single-instance browser application may omit it from subsequent calls.
await createBrowserCurvyConfig();
const balances = await getBalances();Prefer explicit config in shared libraries even when the host application uses the ambient form.
State and subscriptions
config.state is the current serializable snapshot. config.subscribe observes changes without coupling the SDK to a UI framework. Higher-level event actions such as on are useful for lifecycle events.
Lifecycle
Always call destroyConfig when a config's owner is finished with it.
await config.destroy();Creating a replacement ambient config does not destroy the previous one automatically.
Reading config state
getCurvyConfigreads the ambient config and throws when none exists.peekCurvyConfigperforms the same read without throwing.getActiveNetworks,getEnvironment, andgetProtocolread commonly needed config state.setCurvyConfigreplaces or clears the ambient config; it does not destroy the previous value.