Skip to main content

Demo Project

A complete example project demonstrating how to use the Privacy Cash EVM SDK in a Next.js frontend: https://github.com/Privacy-Cash/base-sdk-demo-interface

Installation

Requires Node.js 20+. The SDK is written in TypeScript and includes type definitions.

Wallet Provider Setup

Wrap your app with Wagmi and RainbowKit providers configured for the supported EVM mainnets:

Deriving Encryption Key

Before a user can interact with Privacy Cash, they must sign an off-chain message. This signature is used to derive their private encryption key and UTXO keypair — neither key ever leaves the client.
Auto-prompt the user to sign when they connect their wallet:

Circuit Key File

Place the circuit2.zkey file in your Next.js public/ folder. Pass the base path (without extension) to each SDK function:

Selecting a Network

Pass the active EVM network to SDK calls. Base is the default when network is omitted, but explicit selection keeps multi-chain apps predictable.

Common Issues

  1. Signature re-prompt on every page refresh — Store the signature in localStorage keyed by address as shown above.
  2. walletClient temporarily undefined — Use connector.getProvider() as a fallback when useWalletClient() is unavailable during initial mount.
  3. Wrong chain data — Pass network: BASE_NETWORK or network: ETH_NETWORK to each SDK call after checking the connected wallet chain.