Build your first privacy-preserving auction in minutes with the Shadow Protocol SDK.
Download from nodejs.org
Phantom, Solflare, or any Solana-compatible wallet
Familiarity with TypeScript and async/await
# Using npm npm install @shadow-protocol/client # Using yarn yarn add @shadow-protocol/client # Using bun bun add @shadow-protocol/client
npm install @solana/web3.js @coral-xyz/anchor
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' });
// 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}`);
// 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}`);
// 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`);
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
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 }
Running into issues? Check our troubleshooting guide or join the community.