Skip to main content

Deposit ETH

Deposit ETH into the Privacy Cash privacy pool on Base.
import { deposit } from 'privacycash-evm'

const tx = await deposit({
  depositAmountInput: number,
  keyBasePath: string,
  signature: string,
  address: string,
  txSender: (unsignedTx: any) => Promise<string>
})

Parameters

ParameterTypeRequiredDescription
depositAmountInputnumberYesAmount to deposit in ETH (e.g. 0.1 for 0.1 ETH)
keyBasePathstringYesBase path to the circuit zkey file (without extension)
signaturestringYesWallet signature of the Privacy Cash sign-in message
addressstringYesThe depositor’s EVM wallet address
txSenderFunctionYesCallback that signs and submits the raw transaction, returns tx hash

Returns

The transaction hash (string).

Example

import { ethers } from 'ethers'
import { deposit, SIGN_PRIVACY_MESSAGE } from 'privacycash-evm'

const provider = new ethers.providers.JsonRpcProvider(process.env.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()

const txSender = async (unsignedTx: any) => {
  const tx = await signer.sendTransaction(unsignedTx)
  await tx.wait()
  return tx.hash
}

const txHash = await deposit({
  depositAmountInput: 0.01, // 0.01 ETH
  keyBasePath: './circuits/transaction',
  signature,
  address,
  txSender,
})

console.log('Deposit tx:', txHash)

Deposit Limits

The protocol enforces a maximum deposit amount. Attempting to exceed it will throw:
Please deposit less than X ETH
There is also a minimum deposit amount of 0.001 ETH.
Depositing below the minimum will throw Deposit amount must be at least 0.001 ETH.

Fees

Fee TypeAmount
Protocol feeFree (0)
Network fee~0.0001 ETH (Base transaction fee)

How Deposits Work

1

ZK Proof Generated

The SDK derives your keypair from the signature, scans on-chain UTXOs, and generates a ZK proof consolidating any existing UTXOs with the new deposit amount.
2

Address Screening

Your wallet address is screened for malicious activity before the transaction is built.
3

Transaction Built

An unsigned transaction is created and passed to your txSender callback for signing and submission.
4

UTXO Created

An encrypted UTXO is written on-chain, decryptable only by you.

Consolidation

New deposits are automatically consolidated with your existing private balance:
// First deposit: 0.05 ETH
await deposit({ depositAmountInput: 0.05, ... })

// Second deposit: 0.03 ETH — merged into a single UTXO
await deposit({ depositAmountInput: 0.03, ... })
// Private balance is now 0.08 ETH (minus network fees)