Prerequisites
What you need to integrate with Turbine.cash private transfers
Prerequisites
Section titled “Prerequisites”Before integrating with Turbine.cash private transfers, ensure you have the following:
Required Dependencies
Section titled “Required Dependencies”Node.js / TypeScript
Section titled “Node.js / TypeScript”npm install @solana/web3.js @coral-xyz/anchornpm install [PLACEHOLDER: POSEIDON_NPM_PACKAGE]| Package | Purpose |
|---|---|
@solana/web3.js | Solana blockchain interaction |
@coral-xyz/anchor | Anchor program client |
[PLACEHOLDER: POSEIDON_NPM_PACKAGE] | Poseidon hash function for commitments |
Browser Requirements
Section titled “Browser Requirements”For browser-based applications:
- Wallet adapter: Use
@solana/wallet-adapter-reactor similar - Crypto: Browser-native
crypto.getRandomValues()for secure randomness
Solana Knowledge
Section titled “Solana Knowledge”You should be familiar with:
- Solana transactions and instructions
- PDAs (Program Derived Addresses)
- Token accounts (SPL Token program)
- Anchor IDL and client generation
API Access
Section titled “API Access”The Turbine.cash API requires authentication:
- Wallet signature: Sign a message with your wallet
- Auth token: Receive a JWT-like token for subsequent requests
- Headers: Include the token in
x-api-authheader
See Authentication for the full flow.
Local Storage
Section titled “Local Storage”Your application MUST securely store:
| Data | Purpose | Consequences if Lost |
|---|---|---|
nullifier | 32-byte random value | Cannot withdraw funds |
secret | 32-byte random value | Cannot withdraw funds |
leafIndex | Position in Merkle tree | Cannot generate proof |
Network Requirements
Section titled “Network Requirements”RPC Endpoints
Section titled “RPC Endpoints”You’ll interact with:
| Service | Purpose |
|---|---|
| Solana RPC | Sending deposit transactions |
| Turbine.cash API | Relayer, indexer, authentication |
The Turbine.cash API supports CORS for browser applications. No proxy required.
Development Environment
Section titled “Development Environment”For local development:
# Clone your projectgit clone your-project
# Install dependenciesnpm install
# Set environment variablesexport SOLANA_NETWORK=devnetexport TURBINE_API_URL=https://worker.turbine.cashRecommended: TypeScript
Section titled “Recommended: TypeScript”We recommend TypeScript for type safety:
interface DepositSecrets { nullifier: Uint8Array; // 32 bytes secret: Uint8Array; // 32 bytes commitment: Uint8Array; // 32 bytes leafIndex: number;}
interface WithdrawParams { nullifierHash: Uint8Array; proof: Uint8Array; root: Uint8Array; recipient: string;}