An autonomous on-chain battle simulation and prediction market built on Solana.
Beast Index Arena is a fully autonomous auto-battler where four creatures fight automatically until only one remains. Players interact through a prediction market, trading shares based on how the battle unfolds over time. The market observes but never influences the battle outcome.
The complete system consists of three components working together:
- Smart Contract : Handles all battle logic, betting, and payouts on Solana
- Bot Server: Automatically creates new battles and executes turns every few seconds
- Frontend: Displays live battles and allows users to place bets
- The bot initializes a new battle on-chain with 4 creatures
- The bot executes turns automatically (every 3-5 seconds)
- Each turn, the smart contract randomly selects an attacker and target, calculates damage
- Players watch the battle unfold and place bets on creatures they think will win
- When only one creature survives, the battle ends
- Winners can claim their share of the prize pool
- The bot starts a new battle and the cycle repeats
All game logic happens on the blockchain - the bot simply triggers the transactions. This ensures fairness and transparency.
- Fairness: All 4 creatures start with identical stats (ATK, DEF, SPD, HP)
- Visuals: Only the skins differ - Yeti, Mapinguari, Zmey, and Naga
- RNG & Determinism:
- Target and move selection are randomized on-chain
- Damage calculation is deterministic (e.g., Damage = max(1, ATK - DEF))
- Elimination: When HP hits 0, the creature is removed. The last one standing wins.
Players speculate on the outcome by purchasing shares of a specific creature.
- Speculation: Players analyze battle state, momentum, and RNG events to decide when to enter or exit positions
- Settlement: When the battle ends, backers of the winning creature split the pot
- Winning share value: 1.0
- Losing share value: 0.0
This is the smart contract component of the Beast Index Arena system.
Tech Stack:
- Solana blockchain (devnet)
- Anchor framework (Rust)
- On-chain RNG for target selection
- Deterministic combat calculation
Core Features:
- Battle state management (HP, stats, turn tracking)
- Parimutuel betting market
- Position tracking per user per creature
- Winner settlement and payout distribution
- Battle initialization and turn execution
program/
└── beast_index_arena_contract/
├── src/
│ ├── lib.rs # Main program logic
│ ├── state/ # Account structures
│ └── instructions/ # Transaction handlers
└── Cargo.toml
initialize_battle: Creates a new battle with 4 creaturesexecute_turn: Processes one combat turn (target selection, damage, elimination)place_bet: Allows users to buy shares of a creaturesell_shares: Allows users to sell shares before battle endsclaim_winnings: Distributes payouts to winners after battle endsend_battle: Marks battle as complete and determines winner
- Each creature has ATK, DEF, SPD, and HP stats
- Every turn, a random alive creature attacks another random alive target
- Damage is calculated as: max(1, attacker.ATK - target.DEF)
- When a creature's HP reaches 0, it is eliminated
- Battle continues until only one creature remains
- The last surviving creature is declared the winner
- Players buy shares using SOL (minimum 0.01 SOL)
- Share prices are dynamic based on total pool and creature pool
- All bets go into a total pool
- Winners receive proportional payout: (user_shares / winning_pool) * total_pool
- Losers receive nothing (shares become worthless)
The contract is written in Rust using the Anchor framework and deployed on Solana devnet.
MIT