Client Factories
Factories create a fully configured ZkpClient with platform-specific defaults. Use these instead of constructing ZkpClient directly.
createWebClient — @zk-privacy/web
import { createWebClient } from '@zk-privacy/web';
const client = createWebClient({ chainId: 8453 });
Returns a ZkpClient synchronously. Solver and prover load on demand (first getBalance() or transfer() call). Call await client.preload() to eagerly initialize.
Under the hood: WASM solver, WASM prover (NoirJS + bb.js), IndexedDB for persistent storage, circuits fetched from public CDN.
createNodeClient — @zk-privacy/node
import { createNodeClient } from '@zk-privacy/node';
const client = await createNodeClient({ chainId: 8453 });
Returns a Promise<ZkpClient> (async for thread detection). Solver and prover load on demand.
Under the hood: WASM solver, WASM prover (NoirJS + bb.js), file-based storage, circuits bundled in the package.
Configuration
| Field | Type | Default | Description | Platform |
|---|---|---|---|---|
chainId | number | must be provided | Network chain ID | both |
rpcUrl | string | chain default | RPC endpoint override | both |
tokens | Record<string, Address> | chain defaults | Token map override (e.g. { USD: '0x...' }) | both |
relayerUrl | string | chain default | Gas-sponsored transactions | both |
onProgress | (stage, progress?) => void | optional | Loading progress callback | both |
onLog | (level, category, msg, data?) => void | console.log | SDK log callback | both |
circuitsCdnBaseUrl | string | https://cdn.zkprivacy.dev/circuits/v1 | Circuit JSON CDN base URL | web only |
Direct construction
For custom backends (native mobile, test mocks), construct ZkpClient directly with ZkpClientConfig — see Advanced: ZkpClient internals.