Solana Hacker Hotel DevCon 2025 - Buenos Aires Built for the "Building on Solana" Bootcamp Bounty Challenge
A decentralized betting protocol on Solana that enables trustless wagering between participants with a designated arbiter system or automatic winner revelation.
- Overview
- Features
- Live Demo
- Architecture
- Getting Started
- Smart Contract
- Frontend Application
- Testing
- Security
- Bounty Requirements
- License
Block Battle is a fully on-chain betting protocol that implements:
- Trustless escrow - SOL deposits held securely by the program
- Flexible winner selection - Arbiter-based or automatic random reveal
- Multi-party support - Up to 100 players per bet
- Proportional payouts - Fair distribution for group betting
- Pixel dungeon UI - Engaging retro-themed interface
Traditional betting platforms require trust in centralized operators. Block Battle eliminates this by:
✅ Storing all funds on-chain in program-controlled accounts ✅ Using cryptographic verification for all operations ✅ Enabling transparent, auditable game outcomes ✅ Providing instant, permissionless payouts
-
✅ Two-Party Betting System
- Minimum 2 players required
- SOL deposits held in escrow
- Secure fund management
-
✅ Arbiter Mechanism
- Designated arbiter can declare winner
- Authorization checks prevent tampering
- Time-locked reveal option
-
✅ Payout System
- Winners claim full prize pool
- Protection against double-spending
- Secure withdrawal mechanism
-
✅ Client Application
- Create bets with custom parameters
- Join existing pools
- Check bet status in real-time
- Declare winner (arbiter)
- Claim winnings (winners)
- Time remaining display
-
✅ Extra 1: Group Betting
- Multiple users can bet on the same outcome
- Proportional payout system based on deposit amounts
- Individual contribution tracking
-
✅ Extra 2: Multi-Party Competitions
- Supports up to 100 participants
- 25 different blocks (doors) to choose from
- Flexible winner selection from participant pool
- Complex payout distribution handling
-
✅ Extra 3: Creative Features
- Automatic Mode: On-chain randomness for trustless reveals
- Arbiter Mode: Manual winner declaration by designated judge
- Cancellation System: Refund mechanism for invalid bets
- Pixel Dungeon Theme: Unique retro-gaming UI/UX
- Door/Trap System: 25 doors with different trap types
- Victory Modal: Animated winner celebration
- Multi-Dungeon Management: Track created and joined bets
- Share Links: Easy bet sharing via URL parameters
- Video Demo: View on YouTube
- Program ID:
EqzTrTYgAttzSmVbjpm6t6SBUVT5Ab2zWVTxaYDE9iBF - Network: Solana Devnet
- Explorer: View on Solana Explorer
- Framework: Next.js 14
- Run Locally: See Getting Started
┌─────────────────────────────────────────────────────────┐
│ BetAccount (PDA) │
├─────────────────────────────────────────────────────────┤
│ creator: Pubkey │
│ arbiter: Pubkey │
│ min_deposit: u64 │
│ total_pool: u64 │
│ lock_time: i64 │
│ winner_block: Option<u8> │
│ status: BetStatus (Open/Revealed/Cancelled) │
│ is_automatic: bool │
│ players: Vec<Pubkey> (max 100) │
│ chosen_blocks: Vec<u8> (1-25) │
│ deposits: Vec<u64> │
│ claimed: Vec<bool> │
└─────────────────────────────────────────────────────────┘
- create_bet - Initialize new betting pool
- join_bet - Participate and deposit SOL
- reveal_winner - Arbiter declares winner (manual mode)
- auto_reveal_winner - Automatic random reveal (auto mode)
- claim_winnings - Winners withdraw proportional share
- cancel_bet - Creator cancels before lock time
User A (Creator) User B (Player) User C (Arbiter/Auto)
│ │ │
│ create_bet() │ │
├──────────────────────────┼────────────────────────────┤
│ │ │
│ join_bet() │
│ ├────────────────────────────┤
│ │ (SOL → Escrow) │
│ │ │
│ │ reveal_winner() │
│ │ or │
│ │ auto_reveal_winner() │
│ │◄───────────────────────────┤
│ │ │
│ claim_winnings() │
│ ├────────────────────────────┤
│ │ (Escrow → Winner) │
│ │ │
- Node.js 18+
- Rust 1.70+
- Solana CLI 1.18+
- Anchor CLI 0.31.1
- A Solana wallet (Phantom, Solflare, etc.)
- Devnet SOL for testing
- Clone the repository
git clone https://github.com/yourusername/SOLANA-BET-BUENOS-AIRES.git
cd SOLANA-BET-BUENOS-AIRES- Install dependencies
# Install Anchor dependencies
yarn install
# Install frontend dependencies
cd app
npm install
cd ..- Build the program
anchor build- Deploy to Devnet (optional - already deployed)
# Configure Solana to use devnet
solana config set --url devnet
# Deploy
anchor deploy- Run the frontend
cd app
npm run devOpen http://localhost:3000 in your browser.
solana airdrop 2 YOUR_WALLET_ADDRESS --url devnet- Language: Rust
- Framework: Anchor 0.31.1
- Network: Solana Devnet
- Storage: On-chain PDAs (Program Derived Addresses)
Security Measures:
- ✅ Authorization checks for arbiter
- ✅ Double-spending prevention with
claimedflags - ✅ Overflow protection with
checked_mulandchecked_div - ✅ Input validation for all parameters
- ✅ Status verification before state changes
Error Handling:
- Custom error codes for all failure scenarios
- Descriptive error messages
- Proper revert on invalid operations
programs/block-battle/src/
└── lib.rs # Main program logic
├── Instructions # create_bet, join_bet, reveal_winner, etc.
├── Accounts # CreateBet, JoinBet, RevealWinner, etc.
├── State # BetAccount, BetStatus enum
└── Errors # BetError enum
# Build
anchor build
# Test
anchor test
# Deploy to devnet
anchor deploy --provider.cluster devnet- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Blockchain: @solana/web3.js, @coral-xyz/anchor
- Wallet: @solana/wallet-adapter
- Notifications: react-hot-toast
- Animations: framer-motion
app/src/
├── app/
│ └── page.tsx # Main application page
├── components/
│ ├── CreateBet.tsx # Create new bet form
│ ├── JoinBet.tsx # Join existing bet
│ ├── ManageBet.tsx # Manage created/joined bets
│ ├── OpenBets.tsx # Browse active bets
│ ├── QuickPlayPixel.tsx # Play interface
│ └── pixel-dungeon/ # UI components
│ ├── DungeonHeader.tsx
│ ├── DungeonLayout.tsx
│ ├── PixelDoor.tsx
│ ├── PixelDungeonGrid.tsx
│ └── VictoryModal.tsx
├── lib/
│ ├── anchor.ts # Anchor program setup
│ └── useBlockBattle.ts # Custom hook for contract interaction
└── hooks/
├── useBetsList.ts # Fetch all bets
└── useDungeonReveal.ts # Winner reveal animation
User Interface:
- 🎨 Pixel dungeon theme with retro aesthetics
- 🌙 Dark mode optimized
- 📱 Fully responsive design
- ⚡ Real-time bet status updates
- 🎬 Smooth animations and transitions
Wallet Integration:
- Multiple wallet support (Phantom, Solflare, etc.)
- Auto-connect functionality
- Network detection
- Balance display
Bet Management:
- Create automatic or arbiter-based bets
- Browse all active bets
- Join with custom deposit amounts
- Track created and joined bets separately
- Reveal winners (arbiter)
- Claim winnings (winners)
# Unit tests
anchor test
# Integration tests
cd app
npm run test- Connect Wallet (ensure you're on Devnet)
- Create Bet:
- Choose automatic or arbiter mode
- Set minimum deposit (e.g., 0.1 SOL)
- Set lock time (for automatic mode)
- Click "Forge Dungeon"
- Join Bet:
- Browse active dungeons
- Select a door (1-25)
- Deposit SOL (≥ minimum)
- Click "Enter"
- Reveal Winner:
- Automatic: Wait for lock time, click "Auto-Reveal"
- Arbiter: Select winning door, click "Reveal"
- Claim Winnings:
- If you won, click "Claim Treasure"
- Receive proportional share of pool
Implemented Protections:
- ✅ Access Control: Only arbiter can manually reveal winners
- ✅ Double-Spending: Claimed flag prevents multiple withdrawals
- ✅ Integer Overflow: Using checked arithmetic operations
- ✅ Input Validation: All parameters validated before processing
- ✅ State Verification: Status checks before state transitions
- ✅ Re-entrancy: Anchor framework protection
Potential Improvements:
- Add time-locks for arbiter reveals (currently arbiter can reveal anytime)
- Implement fee mechanism for sustainability
- Add dispute resolution system
- Randomness: Automatic mode uses on-chain pseudo-randomness (timestamp + slot). For production, consider using Chainlink VRF or similar.
- Single Bet per Creator: Current PDA design allows one active bet per creator. See
ARCHITECTURE.mdfor multi-bet solutions.
| Requirement | Status | Implementation |
|---|---|---|
| Two-party betting system | ✅ | join_bet() with escrow |
| Same amount deposits | Supports variable deposits | |
| Arbiter mechanism | ✅ | reveal_winner() |
| Time-locked reveal | ✅ | lock_time + auto_reveal_winner() |
| Payout system | ✅ | claim_winnings() with proportional distribution |
| Client application | ✅ | Next.js 14 web app |
| All required functions | ✅ | Create, join, status, reveal, withdraw |
| Extra | Status | Description |
|---|---|---|
| Extra 1: Group Betting | ✅ | Multiple players on same block, proportional payouts |
| Extra 2: Multi-Party | ✅ | Up to 100 players, 25 blocks, flexible winner selection |
| Extra 3: Creative Features | ✅ | Auto mode, cancellation, pixel UI, share links, etc. |
- ✅ Rust with Anchor Framework
- ✅ Deployed on Solana Devnet
- ✅ Proper error handling and validation
- ✅ Secure against common attack vectors
- ✅ TypeScript client with @solana/web3.js
- ✅ Clean UI with wallet integration
- ✅ Transaction status feedback
- ✅ GitHub repository with source code
- ✅ README with setup instructions
- ✅ Deployed program ID:
EqzTrTYgAttzSmVbjpm6t6SBUVT5Ab2zWVTxaYDE9iBF - ✅ Working client (run locally with
npm run dev) - ✅ Documentation of approach and design decisions
- ✅ Known limitations documented
- PITCH_DECK.pptx - Complete pitch deck for corporate presentations (40+ slides)
- PIXEL_DUNGEON_FLOW.md - Complete game flow with step-by-step walkthrough
- Frontend README - Detailed frontend documentation
- Anchor Docs - Anchor framework documentation
- Solana Docs - Solana blockchain documentation
Why Anchor?
- Type-safe program development
- Automatic account validation
- Built-in error handling
- Better developer experience
Why Next.js?
- Server-side rendering for better SEO
- Optimal performance with App Router
- TypeScript support out of the box
- Great developer experience
Why Pixel Dungeon Theme?
- Unique, memorable user experience
- Gamification increases engagement
- Differentiates from generic betting UIs
- Fun and educational for hackathon demo
- Verifiable Randomness: Integrate Chainlink VRF for provably fair random reveals
- Multi-Bet Support: Allow creators to have multiple active bets
- Tournament Mode: Multi-round competitions with brackets
- NFT Integration: Mint winner NFTs as trophies
- Fee Mechanism: Small protocol fee for sustainability
- Betting History: On-chain event logs and analytics
- Mobile App: Native iOS/Android applications
- Social Features: Leaderboards, achievements, profiles
- Implement bet indexing for faster queries
- Add caching layer for better UX
- Optimize RPC calls with batching
- Implement pagination for large bet lists
This project is licensed under the ISC License - see the LICENSE file for details.
- Superteam Brasil - For organizing the Solana Hacker Hotel bootcamp
Built on Solana • Powered by Anchor • Designed for Gamers
Made with 🔥 in Buenos Aires 🇦🇷