Whisky Gaming Protocol [WORK IN PROGRESS]
A comprehensive, production-ready decentralized gaming infrastructure built on Solana, providing provably fair randomness, liquidity pooling, and complete game state management for blockchain-based gaming applications.
Table of Contents
Overview
Whisky is a sophisticated gaming protocol that enables developers to build trustless, verifiable gaming experiences on the Solana blockchain. The protocol features a robust architecture with built-in randomness verification, liquidity management, and economic sustainability through a carefully designed fee structure.
Key Benefits
- Provably Fair: Cryptographically verifiable randomness generation
- Decentralized Liquidity: Community-driven liquidity pools for any SPL token
- Economic Sustainability: Built-in fee structure supporting long-term viability
- Developer Friendly: Comprehensive SDK and documentation
- Production Ready: Thoroughly tested and audited codebase
Features
Core Functionality
- Multi-token Support: Create gaming pools for any SPL token
- Flexible Betting Structure: Support for any probability distribution
- Provably Fair RNG: Verifiable random number generation
- Liquidity Management: Automated yield distribution to LP token holders
- Progressive Jackpots: Dynamic jackpot accumulation system
- Emergency Controls: Protocol-wide safety mechanisms
Advanced Features
- Program Derived Addresses: Secure account management
- Mathematical Overflow Protection: Safe arithmetic operations
- Comprehensive Error Handling: Robust error management system
- Authority Management: Granular permission controls
- Fee Customization: Configurable fee structures
Architecture
Core Data Structures
WhiskyState (Global Protocol)
pub struct WhiskyState {
pub authority: Pubkey,
pub rng_address: Pubkey,
pub whisky_fee_bps: u64,
pub playing_allowed: bool,
}
Pool (Liquidity Management)
pub struct Pool {
pub pool_authority: Pubkey,
pub underlying_token_mint: Pubkey,
pub min_wager: u64,
pub plays: u64,
}
Game (Individual Sessions)
pub struct Game {
pub wager: u64,
pub bet: Vec<u32>,
pub client_seed: String,
pub rng_seed: String,
pub status: GameStatus,
pub result: u32,
}
Instruction Set
The protocol implements 17 core instructions divided into three categories:
Gaming Instructions:
play_game
- Initiate new gaming session
rng_settle
- Process randomness and determine outcome
player_claim
- Claim winnings
Pool Management:
pool_initialize
- Create new liquidity pool
pool_deposit
- Add liquidity to pool
pool_withdraw
- Remove liquidity from pool
Administrative:
whisky_initialize
- Initialize protocol
update_authority
- Modify protocol settings
Installation
Prerequisites
- Node.js 16.0.0 or higher
- Solana CLI tools
- Anchor framework
- TypeScript 4.5.0 or higher
Install Dependencies
npm install @whisky-core/sdk
Anchor Program
anchor build
anchor deploy
Quick Start
Initialize Protocol
import { WhiskySDK } from '@whisky-core/sdk';
const sdk = new WhiskySDK({
connection: new Connection('https://api.mainnet-beta.solana.com'),
wallet: yourWallet,
programId: WHISKY_PROGRAM_ID
});
await sdk.initializeProtocol({
authority: authorityPublicKey,
rngProvider: rngProviderPublicKey,
protocolFee: 200
});
Create Gaming Pool
const poolAddress = await sdk.createPool({
tokenMint: USDC_MINT_ADDRESS,
minimumWager: 1_000_000,
poolAuthority: poolAuthorityKeypair
});
Add Liquidity
await sdk.depositLiquidity(poolAddress, 1000_000_000);
Play Game
const gameResult = await sdk.playGame({
poolAddress,
wager: 10_000_000,
bet: [50, 50],
clientSeed: 'player_randomness_123',
creatorFee: 100,
jackpotFee: 50,
metadata: 'Coinflip Game #1'
});
await sdk.waitForSettlement(gameResult.gameAddress);
if (gameResult.won) {
await sdk.claimWinnings(gameResult.gameAddress);
}
API Reference
Core Methods
playGame(params: PlayGameParams): Promise<GameResult>
Initiates a new gaming session.
Parameters:
poolAddress: PublicKey
- Target liquidity pool
wager: number
- Bet amount in token base units
bet: number[]
- Outcome probability weights
clientSeed: string
- Player randomness contribution
creatorFee: number
- Creator fee in basis points
jackpotFee: number
- Jackpot fee in basis points
metadata: string
- Game identification string
Returns:
GameResult
- Game session details and outcome
createPool(params: CreatePoolParams): Promise<PublicKey>
Creates a new liquidity pool for specified token.
Parameters:
tokenMint: PublicKey
- SPL token mint address
minimumWager: number
- Minimum acceptable bet
poolAuthority: Keypair
- Pool management authority
Returns:
PublicKey
- Created pool address
depositLiquidity(poolAddress: PublicKey, amount: number): Promise<string>
Deposits tokens into liquidity pool.
Parameters:
poolAddress: PublicKey
- Target pool address
amount: number
- Token amount to deposit
Returns:
string
- Transaction signature
Utility Functions
validateBet(bet: number[]): boolean
Validates betting structure for mathematical correctness.
validateBet([50, 50]);
validateBet([25, 25, 25, 25]);
validateBet([90, 10]);
validateBet([0, 0]);
validateBet([]);
calculatePayout(wager: number, bet: number[], outcome: number): number
Calculates payout for specific outcome.
const payout = calculatePayout(1000000, [50, 50], 0);
calculateJackpotOdds(wager: number, poolSize: number): number
Determines jackpot probability based on wager size.
const odds = calculateJackpotOdds(10000000, 1000000000);
Examples
Binary Prediction Market
const predictionGame = await sdk.playGame({
poolAddress: usdcPool,
wager: 50_000_000,
bet: [60, 40],
clientSeed: 'prediction_12345',
creatorFee: 200,
jackpotFee: 0,
metadata: 'Election Outcome Prediction'
});
Multi-Outcome Casino Game
const diceGame = await sdk.playGame({
poolAddress: solPool,
wager: 5_000_000_000,
bet: [16, 16, 16, 16, 16, 20],
clientSeed: 'dice_roll_789',
creatorFee: 300,
jackpotFee: 100,
metadata: 'Lucky Dice Roll'
});
Slot Machine Simulation
const slotGame = await sdk.playGame({
poolAddress: bonkPool,
wager: 1_000_000_000,
bet: [
500,
300,
150,
40,
9,
1
],
clientSeed: 'slot_machine_456',
creatorFee: 500,
jackpotFee: 200,
metadata: 'Triple 7s Slot Machine'
});
Security
Randomness Generation
The protocol implements a dual-seed randomness system ensuring provable fairness:
- Client Seed: Player provides randomness input
- Server Seed: RNG provider contributes entropy
- Combination: Seeds are cryptographically combined using SHA-256
- Verification: All randomness is publicly verifiable on-chain
Mathematical Integrity
- Overflow Protection: All arithmetic operations use checked math
- Bet Validation: Comprehensive validation of probability distributions
- Payout Limits: Maximum payout restrictions prevent pool drainage
- House Edge Caps: Maximum 3% house edge enforcement
Access Controls
- Authority Management: Granular permission system
- PDA Security: Program Derived Addresses prevent account manipulation
- Emergency Controls: Protocol-wide emergency stop functionality
- Audit Trail: Complete on-chain transaction history
Known Security Considerations
- RNG provider must be trusted for seed generation
- Pool liquidity affects maximum possible payouts
- Smart contract upgrades require governance approval
- Client seed predictability could affect fairness
Economic Model
Fee Structure
From each gaming session, fees are distributed as follows:
Protocol Treasury | 2.0% | Development and maintenance |
Game Creator | 1.0% | Application development incentives |
Liquidity Providers | 1.0% | Yield for LP token holders |
Progressive Jackpot | 0.5% | Exceptional payout accumulation |
Available for Payout | 95.5% | Player winnings pool |
Liquidity Provider Benefits
- Passive Income: Earn fees from all gaming activity
- LP Tokens: Tradeable tokens representing pool ownership
- Proportional Rewards: Earnings scale with liquidity contribution
- No Gaming Risk: Earn fees without direct betting participation
Economic Sustainability
- Protocol fees fund ongoing development
- Creator incentives encourage ecosystem growth
- Liquidity provider rewards ensure adequate pool funding
- Progressive jackpots drive player engagement
Development
Project Structure
whisky-protocol/
├── programs/
│ └── whisky/
│ ├── src/
│ │ ├── lib.rs # Main program entry
│ │ ├── state.rs # Data structures
│ │ ├── instructions/ # Instruction handlers
│ │ ├── utils.rs # Mathematical utilities
│ │ └── errors.rs # Error definitions
│ └── Cargo.toml
├── sdk/
│ ├── src/
│ │ ├── index.ts # Main SDK export
│ │ ├── instructions.ts # Instruction builders
│ │ ├── accounts.ts # Account management
│ │ └── utils.ts # Utility functions
│ └── package.json
├── tests/
│ ├── integration/ # Integration tests
│ ├── unit/ # Unit tests
│ └── fixtures/ # Test data
└── docs/ # Documentation
Building from Source
git clone https://github.com/weknowyourgame/whisky-gaming.git
cd whisky-gaming
npm install
anchor build
npm run build:sdk
npm test
Environment Setup
solana config set --url devnet
solana-keygen new --outfile ~/.config/solana/id.json
solana airdrop 2
Testing
Test Suite
The protocol includes comprehensive testing covering:
- Unit Tests: Individual function validation
- Integration Tests: End-to-end workflow testing
- Mathematical Tests: Probability and payout calculations
- Security Tests: Error handling and edge cases
- Performance Tests: Transaction throughput and costs
Running Tests
npm test
npm run test:unit
npm run test:integration
npm run test:security
npm run test:coverage
Test Examples
describe('Gaming Mathematics', () => {
test('calculates correct payout multipliers', () => {
const multiplier = calculateMultiplier([25, 25, 25, 25], 0);
expect(multiplier).toBe(4.0);
});
test('validates betting structures', () => {
expect(validateBet([50, 50])).toBe(true);
expect(validateBet([0, 0])).toBe(false);
});
test('prevents mathematical overflow', () => {
expect(() => calculatePayout(MAX_U64, [1, 99], 0))
.toThrow('Arithmetic overflow');
});
});
Deployment
Mainnet Deployment
anchor build --verifiable
anchor deploy --provider.cluster mainnet-beta
anchor run initialize-mainnet
Configuration
const MAINNET_CONFIG = {
programId: new PublicKey('WHISKY_PROGRAM_ID'),
rpcEndpoint: 'https://api.mainnet-beta.solana.com',
protocolFee: 200,
maxHouseEdge: 300,
minWager: 1000,
};
Monitoring
- Transaction Success Rate: Monitor settlement success
- Pool Liquidity Levels: Ensure adequate funding
- Fee Collection: Track protocol revenue
- RNG Provider Uptime: Monitor randomness availability
Contributing
Development Workflow
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature
)
- Commit changes (
git commit -m 'Add amazing feature'
)
- Push to branch (
git push origin feature/amazing-feature
)
- Open Pull Request
Code Standards
- Rust: Follow official Rust style guidelines
- TypeScript: Use Prettier and ESLint configurations
- Testing: Maintain 90%+ test coverage
- Documentation: Update docs for all public APIs
Contribution Areas
- Protocol Enhancements: Core functionality improvements
- SDK Development: Client library features
- Documentation: User guides and API documentation
- Testing: Additional test coverage
- Security: Audit and security improvements
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
Documentation
Professional Support
For enterprise integration and custom development:
WhiskyState Protocol - Building the future of decentralized gaming on Solana.