← Back to Documentation

Quick Start Guide

Get up and running with zkHole in under 5 minutes. This guide will walk you through the basic setup and your first anonymous transaction.

Prerequisites

Node.js 18+
Required for running the SDK
Solana Wallet (Phantom, Solflare, etc.)
For signing transactions
Basic JavaScript/TypeScript knowledge
Familiarity with async/await patterns

Step 1: Installation

Install the zkHole SDK and Solana Web3.js library using npm or yarn:

Using npm:
npm install @zkhole/sdk @solana/web3.js
Using yarn:
yarn add @zkhole/sdk @solana/web3.js
Using pnpm:
pnpm add @zkhole/sdk @solana/web3.js

Step 2: Connect Your Wallet

Connect to a Solana wallet. This example uses Phantom, but works with any wallet adapter:

// Check if wallet is available
if (!window.solana) {
  throw new Error('Please install a Solana wallet');
}

// Connect to the wallet
const wallet = await window.solana.connect();
console.log('Connected to wallet:', wallet.publicKey.toString());

// Listen for account changes
window.solana.on('accountChanged', (publicKey) => {
  if (publicKey) {
    console.log('Switched to account:', publicKey.toString());
  } else {
    console.log('Wallet disconnected');
  }
});

Step 3: Initialize zkHole Client

Create a zkHole client instance with your wallet and network configuration:

import { ZkHoleClient } from '@zkhole/sdk';
import { Connection, clusterApiUrl } from '@solana/web3.js';

// Create Solana connection
const connection = new Connection(
  clusterApiUrl('mainnet-beta'),
  'confirmed'
);

// Initialize zkHole client
const client = new ZkHoleClient({
  connection,
  wallet: window.solana,
  network: 'mainnet-beta', // or 'devnet' for testing
});

console.log('zkHole client initialized');

💡 Tip: Use 'devnet' during development to avoid spending real SOL while testing.

Step 4: Send Anonymous Transaction

Send your first anonymous transaction using zkHole:

// Prepare transaction parameters
const txParams = {
  recipient: 'RECIPIENT_WALLET_ADDRESS_HERE',
  amount: 1.5, // Amount in SOL
  memo: 'Optional transaction memo'
};

try {
  // Send anonymous transaction
  const transaction = await client.sendAnonymous(txParams);
  
  console.log('Transaction successful!');
  console.log('Signature:', transaction.signature);
  console.log('Status:', transaction.status);
  console.log('Timestamp:', transaction.timestamp);
  
  // Wait for confirmation
  const confirmation = await client.confirmTransaction(
    transaction.signature
  );
  
  console.log('Transaction confirmed:', confirmation);
} catch (error) {
  console.error('Transaction failed:', error.message);
}

Complete Example

Here's a full working example putting it all together:

import { ZkHoleClient } from '@zkhole/sdk';
import { Connection, clusterApiUrl } from '@solana/web3.js';

async function sendAnonymousTransaction() {
  try {
    // 1. Connect wallet
    if (!window.solana) {
      throw new Error('Please install a Solana wallet');
    }
    
    const wallet = await window.solana.connect();
    console.log('Wallet connected:', wallet.publicKey.toString());
    
    // 2. Create connection
    const connection = new Connection(
      clusterApiUrl('mainnet-beta'),
      'confirmed'
    );
    
    // 3. Initialize client
    const client = new ZkHoleClient({
      connection,
      wallet: window.solana,
      network: 'mainnet-beta',
    });
    
    // 4. Send transaction
    const transaction = await client.sendAnonymous({
      recipient: 'RECIPIENT_ADDRESS_HERE',
      amount: 1.0,
      memo: 'Anonymous transfer via zkHole'
    });
    
    console.log('Success! Signature:', transaction.signature);
    
    return transaction;
  } catch (error) {
    console.error('Error:', error);
    throw error;
  }
}

// Usage
sendAnonymousTransaction()
  .then(() => console.log('Done!'))
  .catch((err) => console.error('Failed:', err));

Next Steps

Need Help?

Join our community for support and updates: