@shuffle-protocol/sdk
v0.4.0
Published
CLI and SDK for the Shuffle privacy protocol on Solana
Maintainers
Readme
@shuffle-protocol/sdk
CLI and SDK for the Shuffle Privacy Protocol on Solana
Shuffle is a privacy-preserving DeFi protocol that uses Multi-Party Computation (MPC) to hide your trading intent until batch execution.
🚀 Quick Start
Installation
npm install -g @shuffle-protocol/sdkPrerequisites
Solana CLI with a keypair:
# Generate if you don't have one solana-keygen new # Configure for devnet solana config set --url devnet
Get Started (Devnet)
# 1. Create your privacy account
shuffle init
# 2. Get test tokens (also airdrops 1 SOL for fees)
shuffle faucet 10000
# 3. Deposit into privacy account
shuffle shield USDC 1000
# 4. Place encrypted order
shuffle order TSLA_USDC buy 500
# Check status
shuffle status
# Settle order after batch execution
shuffle settleOther Commands
# View encrypted balances
shuffle balance
# Withdraw from privacy account
shuffle unshield USDC 500
# Private transfer to another user
shuffle transfer <solana-address> 100
# Get more SOL if needed
shuffle airdrop 2📦 SDK Usage
import {
ShuffleClient,
AssetId,
PairId,
Direction,
} from "@shuffle-protocol/sdk";
// Create client
const client = await ShuffleClient.create({
connection,
wallet,
});
// Initialize encryption
client.initEncryption(yourX25519PrivateKey);
// Create account
await client.createUserAccount();
// Deposit
await client.deposit(AssetId.USDC, 1_000_000_000); // 1000 USDC
// Check balance
const balances = await client.getBalance();
console.log("USDC:", balances.usdc);
// Place order
await client.placeOrder(
PairId.TSLA_USDC,
Direction.AtoB, // Buy TSLA with USDC
500_000_000, // 500 USDC
AssetId.USDC,
);🃏 How It Works
- Deposit tokens into your private account
- Place orders that are encrypted using MPC
- Batch execution aggregates all orders privately
- Settle to receive your pro-rata payout
Your trading intent remains hidden until the batch executes!
🔧 Options
shuffle --help # Show all commands
shuffle --network localnet # Use local validator
shuffle --keypair ~/custom.json # Use custom keypair
shuffle --mock # Mock mode for testingLicense
MIT
