Skip to content

devfoma/real-ayo-game

Repository files navigation

Ayo Game - Gorbagana Testnet Integration

A traditional African board game (Ayo/Oware) built on React with Solana blockchain integration using the Gorbagana testnet.

🎮 Game Overview

Ayo is a traditional African mancala-style board game where players strategically move seeds around pits to capture their opponent's seeds. This implementation brings the classic game to the blockchain with:

  • Local Play: Two players on the same device
  • AI Opponent: Play against a computer opponent
  • Online Play: Blockchain-powered multiplayer with token rewards

🔗 Gorbagana Integration

This game leverages Gorbagana's fast, one-validator Solana-based testnet infrastructure:

🔌 RPC Connection

  • Connected to Gorbagana testnet RPC endpoint
  • Fast transaction confirmation times
  • Reliable network connectivity

👛 Wallet Integration

  • Backpack Wallet support (primary)
  • Phantom Wallet support
  • Solflare Wallet support
  • Seamless wallet connection experience

💰 Test Token Economy

  • Entry Fee: 1.0 test tokens per online game
  • Winner Reward: 1.8 test tokens (90% of pot)
  • Platform Fee: 0.2 test tokens (10% of pot)
  • Built-in test token faucet for easy testing

🔐 On-Chain Smart Contract

  • Anchor-based Solana program
  • Secure game state management
  • Automated reward distribution
  • Transparent game outcomes

🚀 Setup Instructions

Prerequisites

  • Node.js 18+ and pnpm
  • Solana CLI tools
  • Anchor framework

Installation

  1. Clone and install dependencies:
git clone <repository-url>
cd ayo-solana-game
pnpm install
  1. Configure Gorbagana connection:
    • Get RPC URL from Gorbagana Telegram
    • Get test token mint address from the community
    • Update src/config/gorbagana.ts with actual values:
export const GORBAGANA_CONFIG = {
  RPC_URL: 'https://your-gorbagana-rpc-url',
  TEST_TOKEN_MINT: new PublicKey('your-test-token-mint'),
  // ... other config
};
  1. Deploy the smart contract (optional):
# Build the Anchor program
pnpm anchor:build

# Deploy to Gorbagana testnet
pnpm anchor:deploy
  1. Start the development server:
pnpm dev

🎯 How to Play

Local/AI Mode

  1. Select "Local" or "vs AI" game mode
  2. Click "New Game" to start
  3. Click on your pits (bottom row for Player 1) to make moves
  4. Capture seeds by landing your last seed in a pit with exactly 4 seeds total

Online Mode

  1. Connect your wallet (Backpack, Phantom, or Solflare)
  2. Get test tokens using the "Get Test Tokens" button
  3. Select "Online" game mode
  4. Pay the entry fee (1.0 test tokens) to create/join a game
  5. Winner automatically receives 1.8 test tokens

Game Rules

  • Setup: 12 pits (6 per player), 4 seeds per pit initially
  • Objective: Capture more seeds than your opponent
  • Movement: Pick up all seeds from one of your pits, sow counterclockwise
  • Capture: When your last seed makes a pit total exactly 4, capture all 4 seeds
  • End: Game ends when one player has no moves available

🛠 Technical Architecture

Frontend Stack

  • React 19 with TypeScript
  • Tailwind CSS for styling
  • Vite for fast development
  • Solana Wallet Adapter for wallet integration

Blockchain Integration

  • @solana/web3.js for blockchain interactions
  • @solana/spl-token for token operations
  • Anchor for smart contract development
  • Gorbagana testnet for fast, reliable transactions

Key Components

  • WalletProvider: Manages wallet connections
  • TokenBalance: Displays and manages test token balance
  • GameControls: Game mode selection and wallet integration
  • GameBoard: Interactive game board with seed visualization
  • useGameTransactions: Handles blockchain transactions
  • useTokenBalance: Manages token balance state

🔧 Configuration

Environment Variables

The app automatically connects to Gorbagana testnet. Update these values in src/config/gorbagana.ts:

  • RPC_URL: Gorbagana testnet RPC endpoint
  • TEST_TOKEN_MINT: Test token mint address
  • PROGRAM_ID: Deployed smart contract address

Smart Contract

The Anchor program handles:

  • Game initialization with entry fees
  • Player moves validation
  • Winner determination
  • Automatic reward distribution

🧪 Testing

Local Testing

# Run the development server
pnpm dev

# Test wallet connections with different wallet types
# Test token balance fetching and faucet functionality
# Test game logic in all three modes

Blockchain Testing

  1. Connect to Gorbagana testnet
  2. Request test tokens from faucet
  3. Create online games and test entry fee payments
  4. Complete games and verify winner rewards

📱 Demo

[Live Demo Link] - Will be available after deployment

🐦 Social Media

Built for the Gorbagana testnet!

Tweet Template:

🎮 Just built an awesome Ayo game on @Gorbagana_chain testnet! 

Traditional African board game meets blockchain:
✅ Fast transactions on Gorbagana
✅ @backpack wallet integration  
✅ Test token rewards
✅ On-chain game logic

Try it out! 🚀

#GorbaganaTestnet @sarv_shaktimaan @lex_node

[Demo Link]

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly on Gorbagana testnet
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details

🙏 Acknowledgments

  • Gorbagana Team for the fast, reliable testnet infrastructure
  • Solana Foundation for the excellent developer tools
  • Anchor Framework for simplifying smart contract development
  • African Gaming Heritage for inspiring this traditional game implementation

Built with ❤️ for the Gorbagana community

For support and updates, join the Gorbagana Telegram

About

Ayo seed game, native to Africans.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages