Skip to main content

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

ParameterTypeRequiredDescription
RPC_urlstringYesSolana RPC endpoint URL
owner`stringnumber[]Uint8ArrayKeypair`YesPrivate key in various formats
enableDebugbooleanNoEnable verbose debug logging

Supported Private Key Formats

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