SDK for Private Matchmaking on Solana
npm install @1upmonster/duelTypeScript SDK for Duel - a privacy-focused matchmaking protocol on Solana using MagicBlock's Ephemeral Rollups (TEE).
- Privacy-First: Player ELO and queue status hidden in TEE
- Client-Side: Players join queues directly from their wallets (no CPI required)
- Automatic Matching: TEE processes matches based on ELO windows
- Easy Integration: Simple SDK for both game owners and players
``bash`
npm install @1upmonster/duel
Initialize matchmaking infrastructure for your game:
`typescript
import { MatchmakingAdmin } from "@1upmonster/duel";
import { AnchorProvider } from "@coral-xyz/anchor";
const admin = new MatchmakingAdmin(provider);
// 1. Initialize Tenant for your Game Program
await admin.initializeTenant(gameProgramId, {
authority, // optional, defaults to gameProgramId
eloWindow: 200, // optional, default 100
eloOffset: 40, // optional, default 40
eloDataType: 'u16' // optional, default 'u16' (u8/u16/u32/u64)
});
// 2. Initialize a Matchmaking Queue
const tenantPda = admin.getTenantPda(authority);
await admin.initializeQueue(authority, tenantPda);
// 3. Delegate to TEE Validator
await admin.delegateQueue(authority, validatorPubkey);
`
The SDK supports different ELO data types to optimize storage:
- 'u8': 0-255 (1 byte)'u16'
- : 0-65,535 (2 bytes) [DEFAULT]'u32'
- : 0-4,294,967,295 (4 bytes)'u64'
- : 0-18,446,744,073,709,551,615 (8 bytes)
Join the private matchmaking queue:
`typescript
import { MatchmakingPlayer } from "@1upmonster/duel";
const player = new MatchmakingPlayer(provider);
// Join queue (matching happens automatically in TEE)
await player.joinQueue(queuePda, tenantPda, playerProfilePda);
`
Constructor
- new MatchmakingAdmin(provider: AnchorProvider, programId?: PublicKey)
Methods
- initializeTenant(authority, tenantProgramId, eloWindow?, eloOffset?) - Set up game tenantinitializeQueue(authority, tenant)
- - Create matchmaking queuedelegateQueue(authority, validator?)
- - Delegate to TEE validatorgetTenantPda(authority)
- - Derive tenant PDAgetQueuePda(authority)
- - Derive queue PDA
Constructor
- new MatchmakingPlayer(provider: AnchorProvider, programId?: PublicKey)
Methods
- joinQueue(queue, tenant, playerData) - Join matchmaking queue
1. Queue Joining: Players call joinQueue` directly via SDK
2. Matching: TEE automatically processes matches based on ELO windows
3. Privacy: Queue state is only visible within the TEE, not on L1
- GitHub Repository
- Full Documentation
MIT