> ## 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 Withdraw

> Frontend Withdraw on EVM

# withdraw()

`withdraw()` is a function from `privacycash-evm` used to withdraw ETH or a supported ERC-20 token from Privacy Cash to an EVM recipient address.

## Parameters

| Parameter             | Type                        | Description                                                            |
| :-------------------- | :-------------------------- | :--------------------------------------------------------------------- |
| `withdrawAmountInput` | `number`                    | Total amount to withdraw. Fees are deducted from this value.           |
| `recipient`           | `string`                    | The EVM address that will receive the withdrawn funds.                 |
| `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 withdrawer's EVM wallet address.                                   |
| `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 { BASE_NETWORK, ETH_NETWORK, withdraw } from 'privacycash-evm'
import { useAccount, useChainId } from 'wagmi'

export function WithdrawButton() {
    const { address } = useAccount()
    const chainId = useChainId()

    const handleWithdraw = 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
        }

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

        const recipient = '0xRECIPIENT_ADDRESS'

        const txHash = await withdraw({
            withdrawAmountInput: 0.05,  // Total including fees
            recipient,
            keyBasePath: '/circuit',
            signature,
            address,
            token: 'eth',
            network,
        })

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

    return <button onClick={handleWithdraw}>Withdraw 0.05 ETH</button>
}

```

***

## Fee Estimation

To display the estimated received amount before the user submits:

```typescript theme={null}
const RENT_FEE = 0.00025
const FEE_RATE = 35 // basis points, 0.35%

function estimateReceived(withdrawAmount: number): number {
    const flatFee = RENT_FEE                          // 0.00025 ETH
    const rateFee = (withdrawAmount * FEE_RATE) / 10000 // 0.35%
    return withdrawAmount - flatFee - rateFee
}

console.log(estimateReceived(0.1))  // ~0.09940 ETH
```

***

## Notes

* `withdrawAmountInput` is the **total** amount deducted from your private balance; the recipient receives less after fees.
* Always validate that `withdrawAmountInput <= privateBalance` before calling `withdraw()`.
* The recipient must be a valid EVM address (`0x` + 40 hex characters).
* Current token support is Base ETH/USDC and Ethereum ETH/USDT.
