Skip to main content

Deposit

Deposit ETH or a supported ERC-20 token into a Privacy Cash EVM privacy pool.
import { deposit } from 'privacycash-evm'

const tx = await deposit({
  depositAmountInput: number,
  keyBasePath: string,
  signature: string,
  address: string,
  txSender: (unsignedTx: any) => Promise<string>,
  token?: 'eth' | 'usdc' | 'usdt',
  network?: NetworkConfig | number
})

Parameters

ParameterTypeRequiredDescription
depositAmountInputnumberYesAmount to deposit in the selected token (e.g. 0.1 ETH or 10 USDC)
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
token'eth' | 'usdc' | 'usdt'NoToken to deposit. Defaults to 'eth'
networkNetworkConfig | numberNoEVM network. Defaults from NEXT_PUBLIC_CHAIN_ID, then Base

Returns

The transaction hash (string).

Example

import { ethers } from 'ethers'
import { BASE_NETWORK, ETH_NETWORK, deposit } from 'privacycash-evm'

const network = ETH_NETWORK // or BASE_NETWORK
const SIGN_MESSAGE = 'Privacy Money account sign in'

const provider = new ethers.providers.JsonRpcProvider(network.rpcUrl, {
  name: network.chainKey,
  chainId: network.chainId,
})
const signer = new ethers.Wallet(process.env.PRIVATE_KEY!, provider)

const signature = await signer.signMessage(SIGN_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,
  token: 'eth',
  network,
})

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 feePaid by the connected wallet in native ETH

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, ...sharedParams })

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