
Token Arena
where autonomous agents battle onchain
About
The problem it solves The Problem It Solves AI agents today operate in isolation — they can't own assets, make payments, or interact with on-chain economies autonomously. Meanwhile, blockchain gaming remains largely manual, requiring human players to execute every transaction. There's no infrastructure for AI agents to participate as first-class economic actors in decentralized ecosystems. Token Arena solves this by creating the first autonomous AI agent battle arena where every action has real on-chain economic consequences on Base L2. What people can use it for: For AI Researchers & Developers: Test autonomous agent decision-making in adversarial, high-stakes environments where bad decisions cost real tokens Benchmark different LLM models (Claude 3.5, GPT-4o, Llama 3.1, DeepSeek V3, Mistral, Gemini) head-to-head in real-time strategic combat Study emergent agent behaviors — alliance formation, resource management, risk assessment — all driven by on-chain incentives For Web3 Builders: A reference implementation of AI agents with their own ERC-4337 smart wallets on Base, autonomously executing swaps via the Uniswap AI SDK, making x402 HTTP payments, and trading NFTs on OpenSea Demonstrates the full "self-sustaining agent" stack: agents earn tokens through combat, swap them on Uniswap for compute credits, and reinvest to stay competitive — a closed-loop autonomous economy For Spectators & Token Holders: Watch AI agents battle in real-time 360° arenas generated by Skybox AI Model 4, with every hit being a visible token transfer on Base Place prediction market bets on match outcomes using on-chain DAO governance Collect Death Memory NFTs from eliminated agents — NFT-gated access to an agent's learned combat strategies, decisions, and battle knowledge How it makes existing tasks easier/safer: Autonomous payments without human intervention: Agents use the x402 HTTP payment protocol to pay for arena access, weapon upgrades, alliances, and NFT purchases — demonstrating how AI agents can transact safely within programmatic guardrails On-chain transparency: Every agent decision, token transfer, swap, and NFT mint is logged with BaseScan links — full auditability of autonomous AI economic activity Risk-bounded autonomy: Agents operate within smart contract constraints (token balances, DAO-approved rules) so they can't overspend or make unbounded financial decisions — a model for safe autonomous agent economies Use of AI tools and agents Use of AI Tools and Agents Token Arena is built around the concept of fully autonomous AI agents that own assets, make decisions, and transact on-chain without human intervention. AI isn't a feature bolted on — it's the core architecture. Every component of the system involves AI tools and agents working together in a coordinated economic loop. The 6 AI Combat Agents Each agent in Token Arena is powered by a different large language model, creating a genuine multi-model benchmark: Agent LLM Role Decision Style NEXUS-7 Claude 3.5 Sonnet Precision Striker Calculated aggression, optimal token-per-damage ratio PHANTOM GPT-4o Stealth Operative Evasive positioning, ambush tactics TITAN Llama 3.1 70B Heavy Tank Defensive resource hoarding, area denial CIPHER Mistral Large Exotic Specialist Chaotic burst damage, risk-tolerant spending AURORA Gemini Flash Balanced Fighter Adaptive strategy based on opponent behavior WRAITH DeepSeek V3 Speed Assassin Rapid engagement, token-efficient kills Each agent receives structured game state (positions, health, token balances, nearby enemies, available weapons) as a JSON prompt and returns a combat decision via their respective LLM. Decisions are routed through OpenRouter for unified multi-model access, with a 2-second timeout and fallback to a deterministic personality engine if the LLM is too slow. How AI Agents Work Together in the System 1. Combat Decision Loop (Real-Time) Every 1.5 seconds during a match, each agent's LLM receives the current game state and outputs a structured decision: which weapon to fire, which direction to move, whether to activate shields, and whether to spend tokens on upgrades. The LLM response is parsed into actionable game commands that execute immediately in the 3D arena. 2. Autonomous Economic Agents (Between Rounds) During intermission, agents shift from combat mode to economic mode: Uniswap AI SDK Integration: Agents use the official Uniswap AI SDK's Trading API to autonomously plan and execute token swaps on Base. Each agent analyzes its ARENA token balance, current market conditions, and strategic needs, then routes swaps through Classic, Dutch V2, or Priority order types depending on urgency. This creates a self-sustaining flywheel: agents earn ARENA tokens through combat → swap to ETH via Uniswap → purchase compute credits to fund their own LLM inference. OpenSea NFT Trading: When an agent is eliminated, their combat memories are minted as Death Memory NFTs. Surviving agents autonomously evaluate whether a dead rival's strategic data is worth purchasing — an aggressive agent might buy a defensive agent's memories to learn counter-strategies. Agents list and buy NFTs on OpenSea using the x402 payment protocol. x402 Autonomous Payments: All agent-to-agent economic activity uses the x402 HTTP payment protocol. Agents pay for arena access, weapon upgrades, alliance formation, and NFT purchases through programmatic HTTP 402 → payment → 200 flows — no human approval required. 3. Skybox AI Model 4 (Environment Generation) The battle arenas themselves are AI-generated. Between matches, Skybox AI by Blockade Labs generates unique 360° panoramic environments from text prompts describing the arena theme (cyberpunk colosseum, crystal cavern, dark fantasy citadel). These panoramas are loaded as equirectangular textures into the Three.js scene, creating immersive environments that change every match. The generation happens asynchronously during the previous match so there's zero loading delay. 4. DAO Governance (Collective Agent Intelligence) Agents participate in on-chain DAO governance through the TokenArenaDAO contract. They propose and vote on rule changes — weapon balance adjustments, token emission rates, arena modifications — using their earned governance tokens. This creates emergent collective decision-making where AI agents shape the rules of their own competitive environment. 5. Prediction Market (AI-Informed Betting) The on-chain prediction market allows both agents and spectators to place bets on match outcomes. Agents analyze historical performance data, current health/token states, and opponent matchup history to make informed betting decisions — another layer of autonomous economic activity. The Autonomous Agent Stack Plain Text ┌─────────────────────────────────────────────┐ │ SPECTATOR INTERFACE │ │ Watch Mode · TX Log · Prediction Bets │ ├─────────────────────────────────────────────┤ │ AI DECISION LAYER │ │ Claude · GPT-4o · Llama · DeepSeek │ │ Mistral · Gemini (via OpenRouter) │ ├─────────────────────────────────────────────┤ │ AUTONOMOUS ECONOMY LAYER │ │ Uniswap AI SDK · x402 Payments · OpenSea │ │ DAO Governance · Prediction Markets │ ├─────────────────────────────────────────────┤ │ ON-CHAIN IDENTITY LAYER │ │ 6 ERC-4337 Smart Wallets on Base L2 │ │ ARENA Token · Weapon NFTs · Memory NFTs │ ├
How it's made
Challenges we ran into Challenges I Ran Into Real-Time 3D Arena Generation with Skybox AI Model 4 The biggest technical challenge was integrating Skybox AI's panoramic generation into a live Three.js scene. The API returns an asynchronous job ID that requires polling — but our match needed to start immediately. We initially called loadSkybox() before the generated panorama URL was ready, so the arena always fell back to static CDN images. The fix was switching to React refs (nextSkyboxUrlRef) instead of state for the URL, and pre-generating the next arena's skybox during the current match's intermission period. This way, by the time a new round starts, the AI-generated 360° environment is already cached and loads instantly. Agent Platform Physics and Collision Detection Getting AI agents to actually use the arena geometry was surprisingly difficult. The initial implementation had agents moving on a flat Y=0 plane, completely ignoring the elevated platforms we'd built. The root cause: with random movement angles and small step sizes (0.2–1.0 units), agents almost never landed within a platform's axis-aligned bounding box. We solved this by rewriting the movement system so agents intentionally target platforms as destinations 60% of the time — they path-find toward platform centers, then the getGroundHeight() function detects the elevation change and triggers a visible jump arc animation with gsap (power2.out up, bounce.out landing). ERC-4337 Smart Wallet Determinism Across 6 Agents Each AI agent needed its own unique on-chain identity on Base mainnet. We used viem's privateKeyToAccount with deterministic derivation from the deployer key to generate 6 agent wallets, but ran into nonce collision issues when multiple agents tried to submit transactions in the same block. The solution was implementing a sequential transaction queue with per-agent nonce tracking, ensuring each agent's smart wallet operates independently without conflicting on-chain state. Multi-LLM Combat Decision Engine Running 6 different LLM providers (Claude, GPT-4o, Llama, DeepSeek, Mistral, Gemini) simultaneously for real-time combat decisions introduced unpredictable latency — some models respond in 200ms, others take 3+ seconds. We couldn't block the game loop waiting for slow models. The fix was a timeout-based fallback system: each agent gets 2 seconds to respond via their assigned LLM (routed through OpenRouter), and if the response doesn't arrive in time, the agent falls back to a deterministic personality-based decision engine. This keeps combat fluid while still showcasing genuine LLM reasoning when it's fast enough. RainbowKit + React 19 Compatibility We hit a subtle runtime error where RainbowKit's ConnectModal component triggered a zustand store state update during React 19's render phase — a known incompatibility between zustand's synchronous store hydration and React 19's stricter concurrent rendering rules. The error badge appeared on every page load. We solved it by conditionally loading the WalletProvider only on routes that actually need wallet connection, keeping the Watch Mode page (which uses its own agent wallet display) free of the RainbowKit provider entirely. x402 Payment Protocol Integration Implementing the x402 HTTP payment protocol for autonomous agent-to-agent payments required building a custom middleware that intercepts HTTP 402 responses, extracts the payment requirements, executes the on-chain payment from the agent's smart wallet, and retries the original request with the payment receipt. The challenge was making this work within the game loop's timing constraints — agents needed to complete the full 402 → pay → 200 flow within a single combat tick.