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.
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 |
Provide either amount OR base_units, not both. The amount parameter is converted to base units automatically.
Returns
{
tx: string // Transaction signature
}
Example: Deposit USDC
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
const USDT_MINT = new PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')
// Deposit 50 USDT
const result = await client.depositSPL({
mintAddress: USDT_MINT,
amount: 50
})
Example: Using Base Units
// 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:
const result = await client.depositUSDC({
base_units: number
})
Example
// 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.
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
{
tx: string,
recipient: string,
base_units: number, // Amount received
fee_base_units: number, // Fee paid
isPartial: boolean
}
Example: Withdraw USDC
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
const USDT_MINT = new PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')
const result = await client.withdrawSPL({
mintAddress: USDT_MINT,
amount: 25,
recipientAddress: 'RECIPIENT_ADDRESS'
})
Withdraw USDC (Convenience Method)
const result = await client.withdrawUSDC({
base_units: number,
recipientAddress?: string,
referrer?: string
})
Example
// 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.
const balance = await client.getPrivateBalanceSpl(mintAddress: PublicKey | string)
Example
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)
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:
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 |
The rent fee varies by token and covers the Solana account rent for the recipient’s token account if it doesn’t exist.
Requirements
Before depositing SPL tokens, ensure:
- Token account exists: You must have a token account with the SPL token
- Sufficient balance: Enough tokens to cover the deposit amount
- SOL for fees: At least 0.002 SOL for Solana transaction fees
// 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)