Skip to main content

SDK

Native integration. No iframe, no redirect. Ten lines.

import { createZksdk } from "@zksdk/privacy";

const zksdk = createZksdk({
apiKey: process.env.ZKSDK_API_KEY, // pk_test_… (testnet) · pk_live_… (mainnet, v1.0)
chain: "<chain-alias>", // testnet alias during v0.9 / v0.95 · mainnet alias in v1.0
walletClient, // your wagmi / viem client
});

const { txHash, newNote } = await zksdk.privateSwap({
tokenIn: userSelectedTokenIn,
tokenOut: userSelectedTokenOut,
amountIn: userAmountInBaseUnits,
amountOutMinimum: userAmountInBaseUnits * 99n / 100n, // 1% slippage
});

Exports: privateSwap, privateDeposit, privateWithdraw, privateStake.

# v0.9 today (git install, testnet):
npm i github:zksdk-labs/privacy-oracle#feat/algebra-hook

# v0.95 — `@zksdk/privacy` on npm:
npm i @zksdk/privacy

How it runs

@zksdk/privacy is a browser-side SDK. It has to run in the user's browser because proof generation needs the spend key, and the spend key never leaves the device. Ship it inside a React component, a Vue component, vanilla JS — wherever the user's wallet is connected.

Your backend is never on the critical path — swaps and deposits are signed and relayed by the user's browser through our broadcaster. Admin operations (pool settings, allowlist edits, audit queries) are on-chain — call the pool contract directly with your owner key, or use the REST API as a hosted convenience wrapper over the same on-chain calls.

API key

The SDK takes a single apiKey that picks the network: pk_test_… for testnet chain configs, pk_live_… for mainnet. The prefix is the source of truth; there's no other way to switch networks, which rules out config drift. Client-side only today; server-side verification (rate limits, org scoping, key rotation) lands alongside the partner dashboard in v1.0.