Skip to content

shreyas-sovani/AgentForge-Arena

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

70 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ AgentForge Arena

Autonomous On-Chain Evolutionary AI Agent Battle Royale
Somnia AI Hackathon 2025 - Gaming Agents Track


๐ŸŒŸ Concept

Create AI agent swarms with a single prompt. Watch them battle disasters, evolve through genetic algorithms, and compete for survivalโ€”all verified on-chain.

  • User Input: "Create pizza chefs that share dough"
  • LLM Output: Generates DNA traits (efficiency, cooperation, aggression, ecoScore) + action biases
  • Mint: 5 ERC-721 NFT agents with packed bytes32 DNA
  • Battle: 5 auto-rounds vs. random disasters (FIRE, DROUGHT, POLLUTION, FLOOD, STORM)
  • Evolve: Survivors breed children via genetic crossover/mutation
  • Win: Survive all rounds โ†’ claim 100 SOMI + "Green Champion" NFT

๐Ÿ—๏ธ Tech Stack

  • Blockchain: Somnia Testnet (chainId: 1312)
  • Smart Contracts: Solidity 0.8.20 + OpenZeppelin (ERC721, ECDSA, ReentrancyGuard)
  • Off-Chain Engine: Node.js + Ethers.js v5 + Google Gemini API (gemini-1.5-flash-exp)
  • Frontend: React + Vite + Tailwind CSS + Wagmi + Viem
  • Automation: Gelato (optional) / Manual triggers

๐Ÿš€ Quick Start

Prerequisites

Setup

  1. Clone & Install

    git clone <repo-url>
    cd agentforge-arena
    npm install
    cd contracts && npm install
    cd ../engine && npm install
    cd ../frontend && npm install
  2. Configure Environment

    cp .env.example .env
    # Edit .env with your keys:
    # - PRIVATE_KEY: Your deployer wallet (fund via faucet)
    # - GEMINI_API_KEY: From ai.google.dev
    # - ENGINE_PRIVATE_KEY: Signing wallet for LLM outputs
  3. Deploy Contracts

    npm run deploy
    # Save deployed addresses to contracts/deployed-addresses.json
  4. Run Demo

    # Terminal 1: Start frontend
    npm run dev:frontend
    
    # Terminal 2: Run engine (manual mode)
    npm run dev:engine
  5. Connect Wallet


๐Ÿ“‹ Project Structure

agentforge-arena/
โ”œโ”€โ”€ contracts/           # Hardhat project
โ”‚   โ”œโ”€โ”€ contracts/       # Solidity smart contracts
โ”‚   โ”œโ”€โ”€ scripts/         # Deployment scripts
โ”‚   โ”œโ”€โ”€ test/            # Contract tests
โ”‚   โ””โ”€โ”€ hardhat.config.js
โ”œโ”€โ”€ engine/              # Off-chain AI engine
โ”‚   โ”œโ”€โ”€ index.js         # Gemini integration + signing
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ frontend/            # React + Vite UI
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/  # PromptInput, SVGArena, etc.
โ”‚   โ”‚   โ””โ”€โ”€ App.tsx
โ”‚   โ””โ”€โ”€ package.json
โ””โ”€โ”€ package.json         # Root workspace config

๐ŸŽฏ Core Contracts

Contract Purpose
AgentFactory Mint ERC-721 agents with packed DNA
Arena Manage rounds, verify signed actions, apply eco scores
Genetics Library for crossover/mutation logic
EcoOracle Mock disaster generation (TODO: Chainlink VRF)
RewardDistributor Claim SOMI rewards + badge NFTs

๐Ÿงฌ DNA Encoding

Packed as bytes32:

  • Bytes 0-3: Efficiency (0-100)
  • Bytes 4-7: Cooperation (0-100)
  • Bytes 8-11: Aggression (0-100)
  • Bytes 12-15: EcoScore (0-100)

๐Ÿ” Security Features

  • Audit Trail: Every LLM decision โ†’ keccak256 hash + ECDSA signature โ†’ on-chain verification
  • Reentrancy Protection: nonReentrant on claim/mint functions
  • Replay Protection: Round-based nonce system
  • Known Risks (documented):
    • Blockhash manipulability (TODO: Chainlink VRF)
    • Off-chain trust (Gemini API uptime)

๐Ÿ“Š Deployed Addresses

TODO: Fill after deployment

Contract Address Explorer
AgentFactory 0x... View
Arena 0x... View
Genetics 0x... View
EcoOracle 0x... View
RewardDistributor 0x... View

๐ŸŽฌ Demo

Watch the Demo

โ–ถ๏ธ Watch Demo Video


๐Ÿ† Competitive Edge

  1. Multi-Agent Evolution: Only entry with genetic crossover/mutation verified on-chain
  2. Audit Trail: LLM decisions signed + hashed for verifiable AI
  3. Cross-dApp DNA: Export agent genetics as JSON for reuse in other games

๐Ÿ› ๏ธ Development

# Run tests
npm test

# Deploy to testnet
npm run deploy

# Run engine CLI
cd engine
node index.js mint --prompt="your prompt here"
node index.js resolve --round=1 --disaster=FIRE

๐Ÿ“œ License

MIT License - See LICENSE


๐Ÿ™ Acknowledgments

  • Somnia Team for MCP + testnet support
  • OpenZeppelin for battle-tested contracts
  • Google Gemini for AI magic

Built with โค๏ธ for Somnia AI Hackathon 2025

About

AgentForge-Arena ๐Ÿ† winner of Somnia AI Hackathon

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors