> ## Documentation Index
> Fetch the complete documentation index at: https://privacycash.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Frontend Deposit

> Frontend Deposit on EVM

# deposit()

`deposit()` is a function from `privacycash-evm` used to deposit ETH or a supported ERC-20 token into Privacy Cash on an EVM network.

## Parameters

| Parameter            | Type                        | Description                                                                              |
| :------------------- | :-------------------------- | :--------------------------------------------------------------------------------------- |
| `depositAmountInput` | `number`                    | Amount to deposit, denominated in the selected token (e.g. `0.05` ETH or `10` USDC).     |
| `keyBasePath`        | `string`                    | Base path for the circuit zkey (e.g. `'/circuit'`).                                      |
| `signature`          | `string`                    | Wallet signature of the Privacy Cash sign-in message.                                    |
| `address`            | `string`                    | The depositor's EVM wallet address.                                                      |
| `txSender`           | `Function`                  | Callback to sign and submit the raw transaction: `(unsignedTx: any) => Promise<string>`. |
| `token`              | `'eth' \| 'usdc' \| 'usdt'` | Optional. Defaults to `'eth'`.                                                           |
| `network`            | `NetworkConfig \| number`   | Optional. Pass `BASE_NETWORK`, `ETH_NETWORK`, or a supported chain ID.                   |

***

## Example Usage

```typescript theme={null}
'use client'
import { ethers } from 'ethers'
import { BASE_NETWORK, ETH_NETWORK, deposit } from 'privacycash-evm'
import { useAccount, useChainId, useWalletClient } from 'wagmi'

export function DepositButton() {
    const { address, connector } = useAccount()
    const chainId = useChainId()
    const { data: walletClient } = useWalletClient()

    const handleDeposit = async () => {
        if (!address) return
        const network = chainId === 1 ? ETH_NETWORK : chainId === 8453 ? BASE_NETWORK : undefined
        if (!network) {
            alert('Switch to Base or Ethereum mainnet.')
            return
        }

        // Retrieve the stored signature
        const signature = localStorage.getItem(`evm_sign_${address}`)
        if (!signature) {
            alert('Please sign in first.')
            return
        }

        // Build the txSender callback
        const txSender = async (unsignedTx: any) => {
            if (walletClient) {
                return await walletClient.sendTransaction({
                    to: unsignedTx.to as `0x${string}`,
                    data: unsignedTx.data as `0x${string}`,
                    value: BigInt(unsignedTx.value?.toString() ?? '0'),
                })
            }
            // Fallback via ethers BrowserProvider
            const ethereum = await connector?.getProvider()
            const provider = new ethers.BrowserProvider(ethereum as any)
            const signer = await provider.getSigner(address)
            const tx = await signer.sendTransaction(unsignedTx)
            return tx.hash
        }

        const txHash = await deposit({
            depositAmountInput: 0.01,
            keyBasePath: '/circuit',
            signature,
            address,
            txSender,
            token: 'eth',
            network,
        })

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

    return <button onClick={handleDeposit}>Deposit 0.01 ETH</button>
}
```

***

## Notes

* The `txSender` callback receives an unsigned transaction object. Your implementation must sign and submit it, then return the transaction hash as a `string`.
* Always check that the user is connected to a supported EVM mainnet before calling `deposit()`: Base (`8453`) or Ethereum (`1`).
* A small additional native token balance is needed for gas on top of the deposit amount. Validate that the wallet has enough ETH for network fees before proceeding.
* Current token support is Base ETH/USDC and Ethereum ETH/USDT.
