Sample Project
https://github.com/Privacy-Cash/privacy-cash-sdk/blob/main/example/
Installation
npm install privacycash --save
Requires Node.js 24+. The SDK is written in TypeScript and includes type definitions.
Initialization
import { PrivacyCash } from 'privacycash'
const client = new PrivacyCash({
RPC_url: 'YOUR_SOLANA_MAINNET_RPC_URL',
owner: 'YOUR_PRIVATE_KEY',
enableDebug: false // optional
})
Constructor Parameters
| Parameter | Type | Required | Description | | | |
|---|
RPC_url | string | Yes | Solana RPC endpoint URL | | | |
owner | `string | number[] | Uint8Array | Keypair` | Yes | Private key in various formats |
enableDebug | boolean | No | Enable verbose debug logging | | | |
// Base58 encoded string
const client1 = new PrivacyCash({
RPC_url: 'https://...',
owner: '5Jd7...' // Base58 string
})
// Byte array
const client2 = new PrivacyCash({
RPC_url: 'https://...',
owner: [1, 2, 3, ...] // number[]
})
// Uint8Array
const client3 = new PrivacyCash({
RPC_url: 'https://...',
owner: new Uint8Array([1, 2, 3, ...])
})
// Solana Keypair object
import { Keypair } from '@solana/web3.js'
const client4 = new PrivacyCash({
RPC_url: 'https://...',
owner: Keypair.generate()
})
Interacting with Privacy Cash
Once above steps are done, client can query balance, make deposits and withdrawals.