Typescript
Miden Web SDK (@miden-sdk/miden-sdk)
The @miden-sdk/miden-sdk is a browser-focused toolkit designed to enable full-featured interaction with the Miden blockchain directly from web applications. It wraps core functionality provided by the Miden Rust client and compiles to WebAssembly (WASM) with TypeScript bindings, making it ideal for use in wallets, dApps, or browser-based dev tools.
Capabilities
The SDK provides APIs to:
- Interact with the Miden chain (e.g., syncing accounts, submitting transactions)
- Build and manage Miden transactions
- Execute programs in the Miden Virtual Machine (VM)
- Generate zero-knowledge proofs via the Miden Prover
- Support delegated proving setups
- Run entirely in the browser using WASM and web workers
Architecture
The SDK is built from the web-client crate, which:
- Is implemented in Rust and compiled to WebAssembly
- Uses
wasm-bindgento expose JavaScript-compatible bindings - Depends on the rust-client crate, which contains core logic for blockchain interaction
A custom rollup.config.js bundles the WASM module, JS bindings, and web worker into a distributable NPM package.
Installation & Usage
The SDK is published to NPM and can be installed via:
npm install @miden-sdk/miden-sdk
# or
yarn add @miden-sdk/miden-sdk
See the README for full installation instructions and some usage instructions, including code examples for wallet creation, transaction execution, and syncing state.
Resource Management
The WebClient uses a dedicated Web Worker to offload computationally intensive operations like wallet creation, transaction proving, and state synchronization. This keeps the main thread responsive.
When building applications that create multiple WebClient instances (e.g., multi-wallet apps or when switching between networks), it's important to properly clean up instances you no longer need:
// Create client
const client = await WebClient.createClient(rpcUrl);
// ... use the client ...
// Clean up when done to free the worker thread
client.terminate();
Each active WebClient holds a Web Worker thread. Calling terminate() releases this resource. Failure to terminate unused clients may lead to memory leaks in long-running applications.
Note: After calling terminate(), the WebClient instance should not be used for further operations.