Skip to main content

Sample Project

https://github.com/Privacy-Cash/privacy-cash-evm-sdk/blob/main/example/

Installation

npm install privacycash-evm --save
Requires Node.js 20+. The SDK is written in TypeScript and includes type definitions.

Signing In

The SDK uses a wallet signature to derive your private encryption key and UTXO keypair. Ask the user to sign a fixed message:
import { ethers } from 'ethers'
import { SIGN_PRIVACY_MESSAGE } from 'privacycash-evm'

const provider = new ethers.providers.JsonRpcProvider('YOUR_BASE_RPC_URL', {
  name: 'base',
  chainId: 8453,
})
const signer = new ethers.Wallet(process.env.PRIVATE_KEY!, provider)

const signature = await signer.signMessage(SIGN_PRIVACY_MESSAGE)
const address = await signer.getAddress()
The resulting signature and address strings are passed directly to each SDK function. No separate initialization step is required.

Sending Transactions

deposit() requires a txSender callback that signs and submits the raw transaction:
const txSender = async (unsignedTx: any) => {
  const tx = await signer.sendTransaction(unsignedTx)
  await tx.wait()
  return tx.hash
}

Interacting with Privacy Cash

Once the above steps are done, you can check balance, make deposits and withdrawals.

Supported Network

Privacy Cash on Base operates on Base Mainnet (chain ID 8453). There is no testnet deployment.
import { deposit, withdraw, getBalance } from 'privacycash-evm'

Key Path

All functions accept a keyBasePath parameter pointing to the circuit zkey file (without extension):
keyBasePath: './circuits/transaction'  // loads ./circuits/transaction2.zkey
For Next.js projects, place the .zkey file in the public/ folder:
keyBasePath: '/circuit'  // loads /circuit2.zkey from public/