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
| Parameter | Type | Required | Description |
|---|
depositAmountInput | number | Yes | Amount to deposit in ETH (e.g. 0.1 for 0.1 ETH) |
keyBasePath | string | Yes | Base path to the circuit zkey file (without extension) |
signature | string | Yes | Wallet signature of the Privacy Cash sign-in message |
address | string | Yes | The depositor’s EVM wallet address |
txSender | Function | Yes | Callback 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 Type | Amount |
|---|
| Protocol fee | Free (0) |
| Network fee | ~0.0001 ETH (Base transaction fee) |
How Deposits Work
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.
Address Screening
Your wallet address is screened for malicious activity before the transaction is built.
Transaction Built
An unsigned transaction is created and passed to your txSender callback for signing and submission.
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)