Getting Started

Build your first privacy-preserving auction in minutes with the Shadow Protocol SDK.

Prerequisites

Node.js 18+

Download from nodejs.org

Solana Wallet

Phantom, Solflare, or any Solana-compatible wallet

Basic TypeScript Knowledge

Familiarity with TypeScript and async/await

Installation

1. Install the SDK

# Using npm
npm install @shadow-protocol/client

# Using yarn
yarn add @shadow-protocol/client

# Using bun
bun add @shadow-protocol/client

2. Install Peer Dependencies

npm install @solana/web3.js @coral-xyz/anchor

Quick Start

1. Initialize the Client

import { ShadowProtocolClient } from '@shadow-protocol/client';
import { Connection, PublicKey } from '@solana/web3.js';

// Initialize client
const client = new ShadowProtocolClient({
  rpcUrl: 'https://api.devnet.solana.com',
  arciumClusterPubkey: 'your-cluster-pubkey',
  wallet: yourWallet,
  commitment: 'confirmed'
});

2. Create Your First Auction

// Create a sealed-bid auction
const auction = await client.createSealedAuction({
  assetMint: new PublicKey('So11111111111111111111111111111111111111112'), // wSOL
  duration: 3600, // 1 hour
  minimumBid: 1_000_000, // 1 SOL
  reservePrice: 5_000_000, // 5 SOL (encrypted)
});

console.log(`Auction created with ID: ${auction.auctionId}`);

3. Submit an Encrypted Bid

// Submit an encrypted bid
const bid = await client.submitEncryptedBid({
  auctionId: auction.auctionId.toString(),
  amount: 7_000_000, // 7 SOL bid
});

console.log(`Bid submitted: ${bid.signature}`);

4. Settle the Auction

// Wait for auction to end, then settle
const settlement = await client.settleAuction(auction.auctionId);

// Wait for MPC computation
await client.waitForComputation(settlement.signature);

// Get final results
const finalAuction = await client.getAuction(auction.auctionId);
console.log(`Winner: ${finalAuction.winner}`);
console.log(`Final price: ${finalAuction.currentPrice / 1_000_000} SOL`);

Configuration

Environment Variables

Create a .env file in your project root:

# Required
SHADOW_PROTOCOL_PROGRAM_ID=your_program_id
ARCIUM_CLUSTER_PUBKEY=your_cluster_pubkey

# Optional
SOLANA_RPC_URL=https://api.devnet.solana.com
MXE_PUBLIC_KEY=your_mxe_public_key
CLUSTER_OFFSET=0

Client Configuration Options

interface ShadowProtocolConfig {
  rpcUrl: string;                    // Solana RPC endpoint
  programId?: string;                // Shadow Protocol program ID
  clusterOffset?: number;            // Arcium cluster offset
  callbackUrl?: string;              // Callback URL for MPC results
  commitment?: Commitment;           // Transaction commitment level
  wallet?: Wallet;                   // Solana wallet instance
  arciumClusterPubkey?: string;      // Arcium cluster public key
  mxePublicKey?: Uint8Array;         // MPC execution public key
}

Next Steps

💡 Need Help?

Running into issues? Check our troubleshooting guide or join the community.