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

# SPL Tokens

> Deposit and withdraw USDC, USDT, and other SPL tokens

## Supported Tokens

Privacy Cash supports the following SPL tokens:

| Token | Mint Address                                   | Decimals |
| ----- | ---------------------------------------------- | -------- |
| USDC  | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | 6        |
| USDT  | `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` | 6        |
| ZEC   | `A7bdiYdS5GjqGFtxf17ppRHtDKPkkRqbKtR27dxvQXaS` | 8        |
| ORE   | `oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp`  | 11       |
| STORE | `sTorERYB6xAZ1SSbwpK3zoK2EEwbBrc7TZAzg1uCGiH`  | 11       |

***

## Deposit SPL Tokens

Deposit any supported SPL token into Privacy Cash.

```typescript theme={null}
const result = await client.depositSPL({
  mintAddress: PublicKey | string,
  amount?: number,      // Human-readable amount (e.g., 10 for 10 USDC)
  base_units?: number   // Raw amount in base units
})
```

### Parameters

| Parameter     | Type                  | Required     | Description                 |
| ------------- | --------------------- | ------------ | --------------------------- |
| `mintAddress` | `PublicKey \| string` | Yes          | The SPL token mint address  |
| `amount`      | `number`              | One of these | Human-readable token amount |
| `base_units`  | `number`              | One of these | Amount in base units        |

<Info>
  Provide either `amount` OR `base_units`, not both. The `amount` parameter is converted to base units automatically.
</Info>

### Returns

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

### Example: Deposit USDC

```typescript theme={null}
import { PublicKey } from '@solana/web3.js'
import { PrivacyCash } from 'privacycash'

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

const USDC_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')

// Deposit 10 USDC using human-readable amount
const result = await client.depositSPL({
  mintAddress: USDC_MINT,
  amount: 10 // 10 USDC
})

console.log('Deposit tx:', result.tx)
```

### Example: Deposit USDT

```typescript theme={null}
const USDT_MINT = new PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')

// Deposit 50 USDT
const result = await client.depositSPL({
  mintAddress: USDT_MINT,
  amount: 50
})
```

### Example: Using Base Units

```typescript theme={null}
// Deposit 2 USDC using base units (USDC has 6 decimals)
const result = await client.depositSPL({
  mintAddress: USDC_MINT,
  base_units: 2_000_000 // 2 USDC = 2,000,000 base units
})
```

***

## Deposit USDC (Convenience Method)

A convenience method specifically for USDC deposits:

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

### Example

```typescript theme={null}
// Deposit 5 USDC
const result = await client.depositUSDC({
  base_units: 5_000_000 // 5 USDC
})
```

***

## Withdraw SPL Tokens

Withdraw any supported SPL token from your private balance.

```typescript theme={null}
const result = await client.withdrawSPL({
  mintAddress: PublicKey | string,
  amount?: number,
  base_units?: number,
  recipientAddress?: string,
  referrer?: string
})
```

### Parameters

| Parameter          | Type                  | Required     | Description                               |
| ------------------ | --------------------- | ------------ | ----------------------------------------- |
| `mintAddress`      | `PublicKey \| string` | Yes          | The SPL token mint address                |
| `amount`           | `number`              | One of these | Human-readable token amount               |
| `base_units`       | `number`              | One of these | Amount in base units                      |
| `recipientAddress` | `string`              | No           | Recipient wallet. Defaults to your wallet |
| `referrer`         | `string`              | No           | Optional referrer address                 |

### Returns

```typescript theme={null}
{
  tx: string,
  recipient: string,
  base_units: number,      // Amount received
  fee_base_units: number,  // Fee paid
  isPartial: boolean
}
```

### Example: Withdraw USDC

```typescript theme={null}
const USDC_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')

// Withdraw 10 USDC to a clean wallet
const result = await client.withdrawSPL({
  mintAddress: USDC_MINT,
  amount: 10,
  recipientAddress: 'CLEAN_WALLET_ADDRESS'
})

console.log('Withdrew:', result.base_units / 1_000_000, 'USDC')
console.log('Fee:', result.fee_base_units / 1_000_000, 'USDC')
```

### Example: Withdraw USDT

```typescript theme={null}
const USDT_MINT = new PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')

const result = await client.withdrawSPL({
  mintAddress: USDT_MINT,
  amount: 25,
  recipientAddress: 'RECIPIENT_ADDRESS'
})
```

***

## Withdraw USDC (Convenience Method)

```typescript theme={null}
const result = await client.withdrawUSDC({
  base_units: number,
  recipientAddress?: string,
  referrer?: string
})
```

### Example

```typescript theme={null}
// Withdraw 100 USDC
const result = await client.withdrawUSDC({
  base_units: 100_000_000, // 100 USDC
  recipientAddress: 'CLEAN_WALLET'
})
```

***

## Get SPL Balance

Check your private balance for any supported SPL token.

```typescript theme={null}
const balance = await client.getPrivateBalanceSpl(mintAddress: PublicKey | string)
```

### Example

```typescript theme={null}
const USDC_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')

const balance = await client.getPrivateBalanceSpl(USDC_MINT)
console.log('Private USDC:', balance.amount / 1_000_000)
```

***

## Get USDC Balance (Convenience Method)

```typescript theme={null}
const balance = await client.getPrivateBalanceUSDC()
console.log('Private USDC:', balance.amount / 1_000_000)
```

***

## Complete Example

Here's a complete example working with USDC and USDT:

```typescript theme={null}
import { PublicKey } from '@solana/web3.js'
import { PrivacyCash } from 'privacycash'

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

  const recipientAddress = process.env.RECIPIENT_ADDRESS!

  // Token mint addresses
  const USDC_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
  const USDT_MINT = new PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')

  // === USDC Operations ===
  
  // Check initial USDC balance
  let usdcBalance = await client.getPrivateBalanceSpl(USDC_MINT)
  console.log('Initial USDC balance:', usdcBalance.amount / 1e6)

  // Deposit 2 USDC
  const depositUSDC = await client.depositSPL({
    mintAddress: USDC_MINT,
    amount: 2
  })
  console.log('USDC deposit tx:', depositUSDC.tx)

  // Check balance after deposit
  usdcBalance = await client.getPrivateBalanceSpl(USDC_MINT)
  console.log('USDC after deposit:', usdcBalance.amount / 1e6)

  // Withdraw 2 USDC
  const withdrawUSDC = await client.withdrawSPL({
    mintAddress: USDC_MINT,
    amount: 2,
    recipientAddress
  })
  console.log('USDC withdraw tx:', withdrawUSDC.tx)

  // === USDT Operations ===

  // Check initial USDT balance
  let usdtBalance = await client.getPrivateBalanceSpl(USDT_MINT)
  console.log('Initial USDT balance:', usdtBalance.amount / 1e6)

  // Deposit 2 USDT
  const depositUSDT = await client.depositSPL({
    mintAddress: USDT_MINT,
    amount: 2
  })
  console.log('USDT deposit tx:', depositUSDT.tx)

  // Withdraw 2 USDT
  const withdrawUSDT = await client.withdrawSPL({
    mintAddress: USDT_MINT,
    amount: 2,
    recipientAddress
  })
  console.log('USDT withdraw tx:', withdrawUSDT.tx)
}

splExample().catch(console.error)
```

***

## SPL Token Fees

| Token   | Deposit Fee | Withdrawal Fee             |
| ------- | ----------- | -------------------------- |
| All SPL | Free        | Rent fee + 0.35% of amount |

<Note>
  The rent fee varies by token and covers the Solana account rent for the recipient's token account if it doesn't exist.
</Note>

***

## Requirements

Before depositing SPL tokens, ensure:

1. **Token account exists**: You must have a token account with the SPL token
2. **Sufficient balance**: Enough tokens to cover the deposit amount
3. **SOL for fees**: At least 0.002 SOL for Solana transaction fees

```typescript theme={null}
// The SDK will throw helpful errors if requirements aren't met:
// - "Insufficient balance. Need at least X USDC."
// - "Need at least 0.002 SOL for Solana fees."
// - "token not found: [address]" (unsupported token)
```
