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

# Deposit

> Deposit SOL and SPL tokens into Privacy Cash

## Deposit SOL

Deposit SOL into the Privacy Cash privacy pool.

```typescript theme={null}
const result = await client.deposit({
  lamports: number
})
```

### Parameters

| Parameter  | Type     | Required | Description                                         |
| ---------- | -------- | -------- | --------------------------------------------------- |
| `lamports` | `number` | Yes      | Amount in lamports (1 SOL = 1,000,000,000 lamports) |

### Returns

```typescript theme={null}
{
  tx: string // Transaction signature
}
```

### Example

```typescript theme={null}
import { PrivacyCash } from 'privacycash'

const client = new PrivacyCash({
  RPC_url: process.env.SOLANA_RPC_URL!,
  owner: process.env.PRIVATE_KEY!
})

// Deposit 0.1 SOL
const result = await client.deposit({
  lamports: 0.1 * 1_000_000_000 // 100,000,000 lamports
})

console.log('Transaction:', result.tx)
console.log('Explorer:', `https://explorer.solana.com/tx/${result.tx}`)
```

### Deposit Limits

The protocol enforces deposit limits to prevent abuse. Check the current limit before depositing large amounts.

<Warning>
  If you exceed the deposit limit, the transaction will fail with `Don't deposit more than X SOL`.
</Warning>

### Fees

| Fee Type     | Amount                               |
| ------------ | ------------------------------------ |
| Protocol fee | **Free** (0)                         |
| Network fee  | \~0.002 SOL (Solana transaction fee) |

***

## How Deposits Work

<Steps>
  <Step title="Transaction Created">
    The SDK creates a deposit transaction with your signed proof
  </Step>

  <Step title="Relayer Screening">
    Your wallet address is screened through CipherOwl for malicious activity
  </Step>

  <Step title="On-Chain Submission">
    The relayer submits the transaction to Solana
  </Step>

  <Step title="UTXO Created">
    An encrypted UTXO is created and stored on-chain, only decryptable by you
  </Step>
</Steps>

### Zero-Knowledge Proof

When you deposit, the SDK generates a ZK proof that:

1. Proves you own the funds being deposited
2. Creates an encrypted commitment that only you can decrypt
3. Ensures the relayer cannot modify any parameters

```typescript theme={null}
// The SDK handles all ZK proof generation automatically
const result = await client.deposit({
  lamports: 50_000_000 // 0.05 SOL
})
// Behind the scenes:
// 1. ZK proof generated
// 2. Transaction signed
// 3. Sent to relayer
// 4. Confirmed on-chain
```

***

## Consolidation

If you already have a private balance, new deposits are automatically consolidated with existing UTXOs:

```typescript theme={null}
// First deposit: 0.1 SOL
await client.deposit({ lamports: 100_000_000 })

// Check balance
let balance = await client.getPrivateBalance()
console.log(balance.lamports) // 100,000,000

// Second deposit: 0.05 SOL (consolidates with first)
await client.deposit({ lamports: 50_000_000 })

// Balance is combined
balance = await client.getPrivateBalance()
console.log(balance.lamports) // 150,000,000
```

<Info>
  Consolidation happens automatically. You don't need to manage UTXOs manually.
</Info>

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Round Amounts" icon="circle">
    Deposit round, integer amounts (e.g., 1 SOL, 0.5 SOL) to avoid amount-based correlation
  </Card>

  <Card title="Common Amounts" icon="users">
    Use common deposit amounts that others also use to increase your anonymity set
  </Card>
</CardGroup>

### Example: Privacy-Optimized Deposit

```typescript theme={null}
// Good: Round amount
await client.deposit({ lamports: 1_000_000_000 }) // 1 SOL

// Avoid: Unique amount that's easy to trace
await client.deposit({ lamports: 1_234_567_890 }) // 1.23456789 SOL
```

***

## Error Handling

```typescript theme={null}
try {
  const result = await client.deposit({
    lamports: 100_000_000
  })
  console.log('Deposit successful:', result.tx)
} catch (error) {
  if (error.message.includes('Insufficient balance')) {
    console.error('Not enough SOL in wallet')
  } else if (error.message.includes("Don't deposit more than")) {
    console.error('Deposit exceeds protocol limit')
  } else {
    console.error('Deposit failed:', error.message)
  }
}
```

### Common Errors

| Error                           | Solution                        |
| ------------------------------- | ------------------------------- |
| `Insufficient balance`          | Add more SOL to your wallet     |
| `Don't deposit more than X SOL` | Reduce deposit amount           |
| `response not ok`               | Check RPC connection, try again |
