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

# deposit()

`deposit()` is a function from `privacycash/utils` used to deposit SOL into the PrivacyCash protocol.

## Parameters

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

| Parameter            | Type                | Description                                                                                                           |
| :------------------- | :------------------ | :-------------------------------------------------------------------------------------------------------------------- |
| `lightWasm`          | `any`               | The Poseidon hasher instance (usually from `@lightprotocol/hasher.rs`).                                               |
| `connection`         | `Connection`        | Solana web3 connection object.                                                                                        |
| `amount_in_lamports` | `number`            | The amount of SOL to deposit, specified in lamports.                                                                  |
| `keyBasePath`        | `string`            | The base path for loading circuit zkeys (e.g., `'/circuit2'`).                                                        |
| `publicKey`          | `PublicKey`         | The user's Solana public key.                                                                                         |
| `transactionSigner`  | `Function`          | A callback function to sign the generated transaction: `(tx: VersionedTransaction) => Promise<VersionedTransaction>`. |
| `storage`            | `Storage`           | A storage object that implements the Web Storage API (e.g., `localStorage`).                                          |
| `encryptionService`  | `EncryptionService` | An instance of the `EncryptionService` used for encrypting UTXO data.                                                 |
| `referrer`           | `string`            | (Optional) The Solana address of the referrer.                                                                        |

***

## Example Usage

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

const result = await depositSPL({
    mintAddress: new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'), // USDC
    base_units: 1_000_000, // 1 USDC (assuming 6 decimals)
    lightWasm: hasher,
    connection,
    keyBasePath: '/circuit2',
    publicKey: userPublicKey,
    transactionSigner: async (tx: VersionedTransaction) => {
        return await signTransaction(tx)
    },
    storage: localStorage,
    encryptionService,
    referrer: ''
});
```

# depositSPL()

`depositSPL()` is used to deposit SPL tokens (like USDC) into the PrivacyCash protocol.

## Parameters

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

| Parameter           | Type                | Description                                                                             |
| :------------------ | :------------------ | :-------------------------------------------------------------------------------------- |
| `mintAddress`       | `PublicKey`         | The mint address of the SPL token to deposit.                                           |
| `base_units`        | `number`            | The amount of tokens to deposit, specified in base units (e.g., amount \* 10^decimals). |
| `lightWasm`         | `any`               | The Poseidon hasher instance.                                                           |
| `connection`        | `Connection`        | Solana web3 connection object.                                                          |
| `keyBasePath`       | `string`            | The base path for loading circuit zkeys (e.g., `'/circuit2'`).                          |
| `publicKey`         | `PublicKey`         | The user's Solana public key.                                                           |
| `transactionSigner` | `Function`          | A callback function to sign the generated transaction.                                  |
| `storage`           | `Storage`           | A storage object (e.g., `localStorage`).                                                |
| `encryptionService` | `EncryptionService` | An instance of the `EncryptionService`.                                                 |
| `referrer`          | `string`            | (Optional) The Solana address of the referrer.                                          |

## Example Usage

```typescript theme={null}
import { deposit } from "privacycash/utils"

const result = await deposit({
    lightWasm: hasher,
    connection,
    amount_in_lamports: 1_000_000_000, // 1 SOL
    keyBasePath: '/circuit2',
    publicKey: userPublicKey,
    transactionSigner: async (tx: VersionedTransaction) => {
        // let user sign the tx
        return await signTransaction(tx)
    },
    storage: localStorage,
    encryptionService,
    referrer: '' // optional
});
```
