← Back to Documentation

SDK Reference

Complete reference for the zkHole SDK. Learn about all available classes, methods, and configuration options.

Installation

npm install @zkhole/sdk @solana/web3.js

ZkHoleClient

The main client class for interacting with zkHole protocol.

Constructor

new ZkHoleClient(config: ZkHoleConfig)

Parameters:

  • connection: Solana Connection instance
  • wallet: Wallet adapter instance
  • network: 'mainnet-beta' | 'devnet' | 'testnet'
  • timeout(optional): Request timeout in ms (default: 30000)

sendAnonymous()

async sendAnonymous(params: TransactionParams): Promise<Transaction>

Parameters:

  • recipient: Destination wallet address (string)
  • amount: Amount in SOL (number)
  • memo(optional): Transaction memo (string)

Returns:

Promise resolving to Transaction object with signature, status, and timestamp

Example:

const tx = await client.sendAnonymous({
  recipient: 'ABC123...',
  amount: 1.5,
  memo: 'Payment'
});

confirmTransaction()

async confirmTransaction(signature: string): Promise<Confirmation>

Parameters:

  • signature: Transaction signature to confirm (string)

Returns:

Promise resolving to Confirmation object with status and block information

getBalance()

async getBalance(address: string): Promise<number>

Parameters:

  • address: Wallet address to check (string)

Returns:

Promise resolving to balance in SOL (number)

getTransactionHistory()

async getTransactionHistory(limit?: number): Promise<Transaction[]>

Parameters:

  • limit(optional): Maximum number of transactions to return (default: 10)

Returns:

Promise resolving to array of Transaction objects

Type Definitions

ZkHoleConfig

interface ZkHoleConfig {
  connection: Connection;
  wallet: WalletAdapter;
  network: 'mainnet-beta' | 'devnet' | 'testnet';
  timeout?: number;
}

TransactionParams

interface TransactionParams {
  recipient: string;
  amount: number;
  memo?: string;
}

Transaction

interface Transaction {
  signature: string;
  status: 'pending' | 'confirmed' | 'failed';
  timestamp: number;
  amount?: number;
  recipient?: string;
}

Error Handling

The SDK throws typed errors for different failure scenarios:

try {
  const tx = await client.sendAnonymous({
    recipient: 'INVALID_ADDRESS',
    amount: 1.0
  });
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Invalid parameters:', error.message);
  } else if (error instanceof InsufficientFundsError) {
    console.error('Not enough SOL:', error.message);
  } else if (error instanceof NetworkError) {
    console.error('Network issue:', error.message);
  } else {
    console.error('Unknown error:', error);
  }
}

Next Steps