Start building with Styx in 5 minutes
Styx is a privacy-preserving Virtual State Layer for Solana. It provides two mainnet programs:
End-to-end encrypted messaging, private transfers, anonymous voting, and 19 instruction types for privacy-preserving applications.
Private token airdrops using Merkle trees. Distribute to 1M+ recipients while keeping the list completely private.
Install the Styx SDK packages:
npm install @styx-stack/pmp-sdk @styx-stack/whisperdrop-sdk @solana/web3.jsOr with pnpm/yarn:
pnpm add @styx-stack/pmp-sdk @styx-stack/whisperdrop-sdk @solana/web3.jsGenerate an API key from your dashboard:
⚠️ Keep your API key secure! Never commit it to version control.
Send an encrypted message using the PMP SDK:
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
import { StyxPMP, encryptMessage, generateKeyPair } from '@styx-stack/pmp-sdk';
// Connect to Solana
const connection = new Connection('https://api.mainnet-beta.solana.com');
const pmp = new StyxPMP(connection);
// Your wallet
const sender = Keypair.fromSecretKey(/* your secret key */);
const recipient = new PublicKey('RECIPIENT_WALLET_ADDRESS');
// Generate encryption keys (X25519)
const encryptionKeys = generateKeyPair();
// Encrypt and send
const encrypted = encryptMessage(
'Hello from Styx!',
encryptionKeys.secretKey,
recipientPublicKey
);
const signature = await pmp.sendPrivateMessage(
sender,
recipient,
encrypted,
{ stealth: true }
);
console.log('✅ Message sent:', signature);Launch a private token airdrop with WhisperDrop:
import {
WhisperDrop,
buildMerkleTree,
generateCampaignId,
generateNonce
} from '@styx-stack/whisperdrop-sdk';
const whisperdrop = new WhisperDrop(connection);
// Define recipients (kept private!)
const allocations = [
{ recipient: new PublicKey('wallet1...'), amount: 100n * 10n**9n, nonce: generateNonce() },
{ recipient: new PublicKey('wallet2...'), amount: 200n * 10n**9n, nonce: generateNonce() },
// Add up to 1M+ recipients
];
// Build Merkle tree - only root goes on-chain
const campaignId = generateCampaignId();
const { root, proofs } = buildMerkleTree(campaignId, allocations);
// Create campaign (pays 0.01 SOL)
const { campaignPDA, escrowPDA } = await whisperdrop.initCampaign(
authority,
tokenMint,
{
campaignId,
merkleRoot: root,
expiryUnix: BigInt(Date.now() / 1000 + 86400 * 30),
}
);
// Deposit tokens to escrow
await transferTokens(authorityATA, escrowPDA, totalAmount);
console.log('🎉 Airdrop created:', campaignPDA.toBase58());
console.log('📤 Share proofs with recipients to claim!');