x402-privacy-adapter
v0.2.2
Published
Buyer-side privacy adapter for x402 payments using a ZK note pool on EVM.
Readme
x402-privacy-adapter
Buyer-side privacy adapter for x402 payments using a ZK note pool on EVM.
Install
npm install x402-privacy-adapterSmart Contract Setup
You need a deployed PrivacyPoolUSDC and local circuit artifacts (wasm + zkey). In this repo:
npm run zk:compilenpm run zk:setupnpm run zk:export-verifiernpm run compilenpm run deploy:base
The deployed pool address is written to deployments/base-mainnet.json. Full steps live in docs/QUICKSTART.md.
Quickstart (CLI)
x402-privacy init \
--rpc https://... \
--pk 0x... \
--chain 8453 \
--pool 0x... \
--usdc 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \
--wasm ./circuits/build/spend_js/spend.wasm \
--zkey ./circuits/build/spend_final.zkey
x402-privacy deposit --amount 10000000
x402-privacy buy --url https://merchant.example/apiProgrammatic Usage
import { PrivacyAdapter } from 'x402-privacy-adapter';
const adapter = new PrivacyAdapter({
rpcUrl: 'https://...',
privateKey: '0x...',
chainId: 8453,
poolAddress: '0x...',
usdcAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
circuitWasmPath: './circuits/build/spend_js/spend.wasm',
zkeyPath: './circuits/build/spend_final.zkey'
});
await adapter.init();
await adapter.depositPack(10_000_000n);
const res = await adapter.buy('https://merchant.example/api');Notes
- No fallback: if privacy conditions are not met the adapter throws.
- Requires local proving artifacts (wasm + zkey).
- Uses fixed denominations (5/10/20/50/100 USDC base units).
