Skip to main content

Whisky React SDK

The Whisky React SDK provides React components and hooks for seamless integration of the Whisky Gaming Protocol into frontend applications.

Overview

The React SDK serves as the UI layer, providing:
  • React Hooks: Custom hooks for protocol interaction
  • UI Components: Pre-built gaming components
  • Wallet Integration: Seamless wallet connectivity
  • State Management: Application state handling

Features

  • Unified Package: Combines UI components and React hooks in a single package
  • Whisky Protocol Integration: Built specifically for the Whisky Gaming Protocol
  • TypeScript Support: Full TypeScript support with comprehensive type definitions
  • Wallet Integration: Seamless integration with Solana wallet adapters
  • Plugin System: Extensible plugin system for custom functionality
  • Transaction Management: Built-in transaction handling and state management

Installation

Quick Start

Core Components

WhiskyProvider

The main provider that wraps your app and provides access to the Whisky protocol.
Props:

WhiskyPlatformProvider

Provides platform-specific functionality like token selection and pool management.

Hooks

useWhisky()

Main hook for interacting with the Whisky protocol.
Returns:
Example:

usePool()

Get pool information for a specific token.
Parameters:
  • tokenMint: Token mint address
  • poolAuthority: Pool authority address
Returns:
Example:

useBalance()

Get balance information for a wallet and token.
Parameters:
  • wallet: Wallet public key
  • token: Token mint address (optional)
Returns:
Example:

useWalletAddress()

Get the current wallet address.
Returns: string | null Example:

UI Components

TokenValue

Display token values with proper formatting.
Props:
Example:

Canvas

Game canvas component for rendering games.
Props:
Example:

GameButton

Pre-styled button component for gaming actions.
Props:

TokenSelector

Component for selecting tokens for gaming.
Props:

Plugin System

Create custom plugins to extend functionality:
Plugin Interface:
Example Plugin:

Referral System

Built-in referral system support:
Referral Hook:
Example:

Advanced Usage Examples

Complete Gaming Application

Multi-Game Interface

Pool Management Interface

Styling and Theming

Custom Styling

Theme Provider

Error Handling

Global Error Boundary

Hook Error Handling

Performance Optimization

Memoization

Lazy Loading

Testing

Component Testing

Hook Testing

Dependencies

This package requires the following peer dependencies:
  • @whisky-gaming/core: The core Whisky protocol SDK
  • @solana/wallet-adapter-react: Solana wallet integration
  • @solana/web3.js: Solana web3 utilities
  • react: React library
  • react-dom: React DOM

Development

Support

For React SDK support and questions: