Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.whisky.casino/llms.txt

Use this file to discover all available pages before exploring further.

Quick Start Guide

Welcome to the Whisky Gaming Protocol! This guide will help you get up and running quickly, whether you’re a developer building games, a player wanting to participate, or a liquidity provider looking to earn fees.

Prerequisites

Before you begin, make sure you have:
  • Solana Wallet: Phantom, Solflare, or any Solana wallet
  • SOL: Some SOL for transaction fees
  • Node.js: Version 16.0.0 or higher (for developers)
  • Basic Knowledge: Understanding of Solana and blockchain concepts

For Players

1. Connect Your Wallet

First, connect your Solana wallet to a Whisky-powered platform:
// Example wallet connection
import { useWallet } from '@solana/wallet-adapter-react';

const { connect, connected, wallet } = useWallet();

if (!connected) {
  return <button onClick={connect}>Connect Wallet</button>;
}

2. Choose a Game

Browse available games on platforms like:

3. Place Your First Bet

// Example game interaction
import { useWhisky } from '@whisky-gaming/ui';

const { play, isPlaying } = useWhisky();

const handlePlay = async () => {
  await play({
    wager: 1000000, // 1 USDC (in base units)
    bet: [50, 50], // 50/50 chance
    creator: 'GAME_CREATOR_ADDRESS',
    clientSeed: 'my_random_seed_123'
  });
};

4. Wait for Settlement

Games are settled automatically by the RNG provider:
// Wait for game settlement
const { game, result } = useWhisky();

if (game && result) {
  console.log(`Game result: ${result.won ? 'Won!' : 'Lost'}`);
  console.log(`Payout: ${result.payout}`);
}

For Developers

1. Install Dependencies

# Install Core SDK
npm install @whisky-gaming/core

# Install React SDK (for frontend)
npm install @whisky-gaming/ui

# Install Solana dependencies
npm install @solana/web3.js @solana/wallet-adapter-react

2. Initialize SDK

import { WhiskySDK } from '@whisky-gaming/core';
import { Connection, Keypair } from '@solana/web3.js';

const sdk = new WhiskySDK({
  connection: new Connection('https://api.mainnet-beta.solana.com'),
  wallet: yourWallet,
  programId: WHISKY_PROGRAM_ID
});

3. Create Your First Pool

// Create a USDC gaming pool
const poolAddress = await sdk.createPool({
  tokenMint: USDC_MINT_ADDRESS,
  minimumWager: 1_000_000, // 1 USDC
  maximumWager: 100_000_000, // 100 USDC
  poolAuthority: poolAuthorityKeypair,
  feeBps: 100 // 1% fee
});

console.log('Pool created:', poolAddress.toString());

4. Build a Simple Game

// Simple coinflip game
function CoinflipGame() {
  const { play, isPlaying, game } = useWhisky();
  const [wager, setWager] = useState(1000000); // 1 USDC

  const handlePlay = async () => {
    try {
      await play({
        poolAddress: poolAddress,
        wager: wager,
        bet: [50, 50], // Equal probability
        clientSeed: `flip_${Date.now()}`,
        creatorFee: 100, // 1%
        jackpotFee: 50,  // 0.5%
        metadata: 'Coinflip Game'
      });
    } catch (error) {
      console.error('Game failed:', error);
    }
  };

  return (
    <div>
      <input
        type="number"
        value={wager}
        onChange={(e) => setWager(Number(e.target.value))}
        placeholder="Wager amount (in base units)"
      />
      <button onClick={handlePlay} disabled={isPlaying}>
        {isPlaying ? 'Playing...' : 'Flip Coin'}
      </button>
      {game && (
        <div>
          <h3>Game Result</h3>
          <p>Status: {game.status}</p>
          {game.result && (
            <p>Outcome: {game.result === 0 ? 'Heads' : 'Tails'}</p>
          )}
        </div>
      )}
    </div>
  );
}

For Liquidity Providers

1. Find a Pool

Browse available pools on the Whisky Explorer:
// Get pool information
const poolInfo = await sdk.getPoolInfo(poolAddress);
console.log('Pool liquidity:', poolInfo.totalLiquidity);
console.log('Pool volume:', poolInfo.totalVolume);

2. Deposit Liquidity

// Deposit 1000 USDC to earn fees
const signature = await sdk.depositLiquidity(
  poolAddress,
  1000_000_000 // 1000 USDC in base units
);

console.log('Deposit successful:', signature);

3. Monitor Earnings

// Check LP token balance
const lpBalance = await sdk.getLPTokenBalance(poolAddress, walletAddress);
console.log('LP tokens owned:', lpBalance);

// Calculate earnings
const earnings = await sdk.calculateLPFees(poolAddress, lpBalance);
console.log('Total fees earned:', earnings);

4. Withdraw Liquidity

// Withdraw liquidity
const withdrawSignature = await sdk.withdrawLiquidity(
  poolAddress,
  lpBalance // Withdraw all LP tokens
);

console.log('Withdrawal successful:', withdrawSignature);

Advanced Examples

Multi-Outcome Game

// Six-sided dice game
const diceGame = await sdk.playGame({
  poolAddress: solPool,
  wager: 5_000_000_000, // 5 SOL
  bet: [16, 16, 16, 16, 16, 20], // Slightly favor outcome 6
  clientSeed: 'dice_roll_789',
  creatorFee: 300, // 3% house edge
  jackpotFee: 100, // 1% progressive jackpot
  metadata: 'Lucky Dice Roll'
});

Prediction Market

// Binary prediction market
const predictionGame = await sdk.playGame({
  poolAddress: usdcPool,
  wager: 50_000_000, // 50 USDC
  bet: [60, 40], // 60% probability for "Yes"
  clientSeed: 'prediction_12345',
  creatorFee: 200, // 2% to market creator
  jackpotFee: 0,   // No jackpot for predictions
  metadata: 'Election Outcome Prediction'
});

Slot Machine

// Complex probability distribution
const slotGame = await sdk.playGame({
  poolAddress: bonkPool,
  wager: 1_000_000_000, // 1B BONK tokens
  bet: [
    500, // 50% - No win
    300, // 30% - Small win (2x)
    150, // 15% - Medium win (5x)
    40,  // 4% - Large win (20x)
    9,   // 0.9% - Huge win (100x)
    1    // 0.1% - Jackpot (1000x)
  ],
  clientSeed: 'slot_machine_456',
  creatorFee: 500, // 5% house edge
  jackpotFee: 200, // 2% progressive jackpot
  metadata: 'Triple 7s Slot Machine'
});

Testing

Local Development

# Set Solana to devnet
solana config set --url devnet

# Request test SOL
solana airdrop 2

# Run tests
npm test

Test Game Flow

describe('Game Flow', () => {
  test('should complete full game cycle', async () => {
    // Create pool
    const poolAddress = await sdk.createPool(poolParams);
    
    // Add liquidity
    await sdk.depositLiquidity(poolAddress, 1000000000);
    
    // Play game
    const gameResult = await sdk.playGame(gameParams);
    
    // Wait for settlement
    const settlement = await sdk.waitForSettlement(gameResult.gameAddress);
    
    // Claim winnings if won
    if (settlement.won) {
      await sdk.claimWinnings(gameResult.gameAddress);
    }
    
    expect(settlement).toBeDefined();
  });
});

Best Practices

Security

  1. Validate Inputs: Always validate user inputs before sending transactions
  2. Handle Errors: Implement proper error handling for all operations
  3. Test Thoroughly: Test your games extensively before deployment
  4. Monitor Transactions: Track transaction success and failure rates

Performance

  1. Batch Operations: Group multiple operations when possible
  2. Cache Data: Cache frequently accessed data
  3. Optimize Queries: Use efficient database queries
  4. Monitor Costs: Track transaction costs and optimize

User Experience

  1. Clear Feedback: Provide clear feedback for all user actions
  2. Loading States: Show loading states during transactions
  3. Error Messages: Display helpful error messages
  4. Mobile Support: Ensure your app works on mobile devices

Next Steps

Now that you’re familiar with the basics, explore:

Support

Need help? Get support from: Happy building! 🎮