Whisky Core SDK
The Whisky Core SDK is a comprehensive TypeScript library that provides direct interaction with the Whisky Gaming Protocol smart contracts on Solana. It abstracts complex blockchain operations and provides type-safe interfaces for building gaming applications.Overview
The Core SDK serves as the protocol layer, handling:- Smart Contract Calls: Direct blockchain interactions
- Transaction Building: Creating and signing transactions
- Account Management: PDA derivation and management
- Protocol Logic: Mathematical calculations and validations
Installation
Prerequisites
- Node.js 16.0.0 or higher
- Solana CLI tools
- Anchor framework
- TypeScript 4.5.0 or higher
Install Dependencies
Anchor Program
Quick Start
Initialize SDK
Initialize Protocol
Create Gaming Pool
Add Liquidity
Play Game
Core API Reference
WhiskySDK Class
Constructor
Gaming Methods
playGame(params: PlayGameParams): Promise<GameResult>
Initiates a new gaming session.
Parameters:
waitForSettlement(gameAddress: PublicKey): Promise<GameSettlement>
Waits for game settlement and returns the result.
Returns:
claimWinnings(gameAddress: PublicKey): Promise<string>
Claims winnings from a settled game.
Returns: Transaction signature
Pool Management
createPool(params: CreatePoolParams): Promise<PublicKey>
Creates a new liquidity pool for specified token.
Parameters:
depositLiquidity(poolAddress: PublicKey, amount: number): Promise<string>
Deposits tokens into liquidity pool.
Parameters:
poolAddress: Target pool addressamount: Token amount to deposit (in base units)
withdrawLiquidity(poolAddress: PublicKey, lpTokenAmount: number): Promise<string>
Withdraws liquidity from pool.
Parameters:
poolAddress: Target pool addresslpTokenAmount: LP token amount to burn
getPoolInfo(poolAddress: PublicKey): Promise<PoolInfo>
Gets pool information.
Returns:
Account Management
getWhiskyState(): Promise<WhiskyState>
Gets global protocol state.
Returns:
getGameInfo(gameAddress: PublicKey): Promise<GameInfo>
Gets game information.
Returns:
Utility Functions
validateBet(bet: number[]): boolean
Validates betting structure for mathematical correctness.
calculatePayout(wager: number, bet: number[], outcome: number): number
Calculates payout for specific outcome.
calculateJackpotOdds(wager: number, poolSize: number): number
Determines jackpot probability based on wager size.
deriveGameAddress(poolAddress: PublicKey, player: PublicKey, nonce: number): PublicKey
Derives game account address.
Advanced Usage Examples
Binary Prediction Market
Multi-Outcome Casino Game
Slot Machine Simulation
Batch Operations
Error Handling
Mathematical Utilities
Probability Calculations
House Edge Calculations
Transaction Management
Custom Transaction Options
Transaction Monitoring
Security Considerations
Input Validation
Error Handling
Transaction Safety
Performance Optimization
Connection Management
Batch Transactions
Testing
Unit Testing
Integration Testing
Deployment
Mainnet Configuration
Devnet Configuration
Support
For SDK support and questions:- Documentation: This documentation
- Examples: GitHub Examples
- Community: Discord Server
- Issues: GitHub Issues
- Email: support@whisky.casino
