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

# withdraw()

`withdraw()` is a function from `privacycash/utils` used to withdraw SOL from the PrivacyCash protocol to a specified recipient address.

## Parameters

The `withdraw()` function takes a configuration object with the following properties:

| Parameter            | Type                | Description                                                                  |
| :------------------- | :------------------ | :--------------------------------------------------------------------------- |
| `amount_in_lamports` | `number`            | The amount of SOL to withdraw, specified in lamports.                        |
| `connection`         | `Connection`        | Solana web3 connection object.                                               |
| `encryptionService`  | `EncryptionService` | An instance of the `EncryptionService` used for decrypting UTXO data.        |
| `keyBasePath`        | `string`            | The base path for loading circuit zkeys (e.g., `'/circuit2'`).               |
| `publicKey`          | `PublicKey`         | The owner's Solana public key.                                               |
| `storage`            | `Storage`           | A storage object that implements the Web Storage API (e.g., `localStorage`). |
| `recipient`          | `PublicKey`         | The Solana address that will receive the withdrawn funds.                    |
| `lightWasm`          | `any`               | The Poseidon hasher instance (usually from `@lightprotocol/hasher.rs`).      |

***

## Example Usage

```typescript theme={null}
import { withdrawSPL } from "privacycash/utils"
import { PublicKey } from "@solana/web3.js"

const result = await withdrawSPL({
    mintAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
    base_units: 1_000_000, // 1 USDC
    connection: connection,
    encryptionService: encryptionService,
    keyBasePath: '/circuit2',
    publicKey: userPublicKey,
    storage: localStorage,
    recipient: new PublicKey('...'),
    lightWasm: hasher,
});
```

# withdrawSPL()

`withdrawSPL()` is used to withdraw SPL tokens from the PrivacyCash protocol to a specified recipient address.

## Parameters

The `withdrawSPL()` function takes a configuration object with the following properties:

| Parameter           | Type                | Description                                                |
| :------------------ | :------------------ | :--------------------------------------------------------- |
| `mintAddress`       | `string`            | The mint address of the SPL token.                         |
| `base_units`        | `number`            | The amount of tokens to withdraw, specified in base units. |
| `connection`        | `Connection`        | Solana web3 connection object.                             |
| `encryptionService` | `EncryptionService` | An instance of the `EncryptionService`.                    |
| `keyBasePath`       | `string`            | The base path for loading circuit zkeys.                   |
| `publicKey`         | `PublicKey`         | The owner's Solana public key.                             |
| `storage`           | `Storage`           | A storage object (e.g., `localStorage`).                   |
| `recipient`         | `PublicKey`         | The Solana address that will receive the withdrawn funds.  |
| `lightWasm`         | `any`               | The Poseidon hasher instance.                              |

## Example Usage

```typescript theme={null}
import { withdraw } from "privacycash/utils"
import { PublicKey } from "@solana/web3.js"

const result = await withdraw({
    amount_in_lamports: 1_000_000_000, // 1 SOL
    connection: connection,
    encryptionService: encryptionService,
    keyBasePath: '/circuit2',
    publicKey: userPublicKey,
    storage: localStorage,
    recipient: new PublicKey('...'), // Recipient address
    lightWasm: hasher,
});
```
