Complete reference for the zkHole SDK. Learn about all available classes, methods, and configuration options.
npm install @zkhole/sdk @solana/web3.jsThe main client class for interacting with zkHole protocol.
new ZkHoleClient(config: ZkHoleConfig)Parameters:
connection: Solana Connection instancewallet: Wallet adapter instancenetwork: 'mainnet-beta' | 'devnet' | 'testnet'timeout(optional): Request timeout in ms (default: 30000)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'
});async confirmTransaction(signature: string): Promise<Confirmation>Parameters:
signature: Transaction signature to confirm (string)Returns:
Promise resolving to Confirmation object with status and block information
async getBalance(address: string): Promise<number>Parameters:
address: Wallet address to check (string)Returns:
Promise resolving to balance in SOL (number)
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
interface ZkHoleConfig {
connection: Connection;
wallet: WalletAdapter;
network: 'mainnet-beta' | 'devnet' | 'testnet';
timeout?: number;
}interface TransactionParams {
recipient: string;
amount: number;
memo?: string;
}interface Transaction {
signature: string;
status: 'pending' | 'confirmed' | 'failed';
timestamp: number;
amount?: number;
recipient?: string;
}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);
}
}