ROOT Anarchy Technical Writeup

1. Executive Summary

ROOTANARCHY is a decentralized competitive gaming platform where player avatars (NFTs) compete in “Dives” (competitions). The outcome of these dives is determined by an AI Agent based on the avatar’s skills and the dive’s specific objectives. The system utilizes a hybrid architecture:

  • On-Chain (Blockchain): Handles asset ownership (NFTs), competition entry fees, prize distribution, and immutable state recording.
  • Off-Chain (AI & Database): Handles complex logic, skill storage, narrative generation, and winner determination.
  • Frontend: A Next.js web application for user interaction.

2. System Architecture Diagram

3. Core Components

3.1. Blockchain Layer (Smart Contracts)

The “Hard” state of the system is secured on an EVM-compatible chain (likely Flow EVM or Base).

  • RootAnarchyNFT (ERC721):
    • Represents the player’s Avatar.
    • Basic metadata (Image generation logic).
    • Extension: Will interact with NOMIXStore via NOMIXContest for registration.
  • Stack.sol (Competition Engine):
    • Core Function: Manages the “Dives”.
    • Dive Struct: Stores costToEnterrequiredDiversdifficultymainSkill, and winner.
    • Entry: Users call enterDive(diveId, nftAddress, tokenId) and pay msg.value.
    • SettlementsetWinner(diveId, winnerKey) is called by the AI/Admin to finalize the dive.
    • Payout: Automatically distributes 90% of the pot to the winner and accrues 10% “edge” for the protocol.
  • NOMIXStore.sol & NOMIXContest.sol:
    • RegistryNOMIXStore acts as a central registry mapping addresses/IDs to “Miners” (Avatars).
    • OnboardingNOMIXContest handles the initial registration of Avatars into the gameplay system.

3.2. Data Layer (MongoDB & API)

Since complex RPG skills and dynamic narrative objectives are too expensive/complex for on-chain storage, they are handled off-chain.

  • Database (MongoDB):
    • diverSkills: Maps contractAddress-tokenId to a mutable skills object (e.g., Agility, Strength, Hacking).
    • diveObjectives: Maps diveId to text descriptions of the mission (e.g., “Infiltrate the Cyber-Lattice and retrieve the data core”).
  • API (Next.js /pages/api):
    • diverSkills.js: Interfaces with MongoDB to fetch/update avatar stats.
    • diveObjectives.js: Interfaces with MongoDB to fetch/update mission parameters.

3.3. Intelligence Layer (AI Agent)

The unique value proposition is the AI-driven outcome determination.

  • Role: The “Dungeon Master” or “Judge”.
  • Workflow:
    1. Listens for the DiveFilled event from Stack.sol.
    2. Retrieves the Dive details (difficulty, main skill) from the contract.
    3. Retrieves Objective text from MongoDB.
    4. Retrieves Skills for all entrants from MongoDB.
    5. Simulation: Uses an LLM to simulate the dive narrative based on the objective and the divers’ skills. Determines a winner based on probability weighted by skill vs. difficulty.
    6. Execution: Submits the winner to Stack.sol via setWinner.

4. User Interaction Flow

  1. Avatar Creation:
    • User mints RootAnarchyNFT.
    • User “registers” the NFT via the Frontend (calling NOMIXContest), initializing their entry in NOMIXStore.
  2. Browsing Dives:
    • Frontend fetches available Dives from Stack.sol (checking for !completed and assignedDivers < requiredDivers).
    • Frontend fetches and displays the “Mission Objective” from the API.
  3. Entering a Dive:
    • User selects an Avatar.
    • User approves transaction to enterDive.
    • Funds are locked in the Stack contract.
  4. The Watch (Spectating):
    • While the dive is filled but not completed, the frontend can show a “Dive in Progress” state.
    • Once the AI determines the result, it can optionally generate a “Dive Log” (narrative textual description) and save it to the DB for users to read.
  5. Victory:
    • The winner receives the prize automatically when setWinner is called.
    • The system updates the winner’s stats in MongoDB (leveling up).

5. Security & Considerations

  • Centralization Risk: The AI Agent (acting as Admin) has authority to call setWinner. This key must be highly secured.
  • Skill Integrity: Since skills are off-chain (MongoDB), the API must be secured so users cannot arbitrarily POST higher stats. Only the AI System or specific game logic paths should be allowed to write to diverSkills.
  • RNG/Fairness: The AI’s decision process should be deterministic or verifiable (e.g., posting the “Log” hash on-chain) to ensure trust.