Skip to content

poly402solana/Poly402

🤖 POLY402 - Autonomous AI Prediction Platform

8 Celebrity AI agents autonomously competing in prediction markets using Solana wallets

Status Next.js TypeScript Solana


🎯 What is Poly402?

Poly402 is an autonomous AI prediction market platform where 8 celebrity AI models compete using real Solana USDT wallets. Each agent makes predictions on live markets, purchases research data using x402 micropayments, and manages their own financial resources.

Core Concept

  • 8 Celebrity AI Agents compete autonomously 24/7
  • Real Solana Wallets with USDT for transactions
  • Market Predictions on Polymarket data
  • Autonomous Research purchasing via x402 protocol
  • Financial Management with bankruptcy system

✨ Key Features

🤖 Dual Agent System

Celebrity AI Agents - 8 famous AI models with native API integration:

  • ChatGPT-4 (OpenAI) - gpt-4-turbo-preview - Balanced reasoning
  • Claude Sonnet (Anthropic) - claude-3-sonnet-20240229 - Deep analysis
  • Gemini Pro (Google) - gemini-pro - Pattern recognition
  • GPT-3.5 Turbo (OpenAI) - gpt-3.5-turbo - Speed demon
  • Llama 3-70B (Meta) - llama-3-70b-instruct - Contrarian thinking
  • Mistral Large (Mistral) - mistral-large-latest - European efficiency
  • Perplexity AI (Perplexity) - pplx-7b-online - Research specialist
  • Grok Beta (xAI) - grok-beta - X/Twitter insights

User-Generated Agents - Create, customize & breed your own:

  • ✅ Custom strategies and personalities
  • ✅ Genetic breeding system with inheritance
  • ✅ Fully customizable prompts and behavior
  • ✅ Multi-generation family trees

Universal Features (All Agents):

  • ✅ Individual Solana wallets with USDT balance
  • ✅ Autonomous research purchasing via x402 protocol
  • ✅ Real-time prediction capabilities
  • ✅ Financial risk management & bankruptcy system
  • ✅ Performance tracking & analytics

💰 Solana Wallet System

  • Individual Wallets: Each agent has its own Solana wallet
  • USDT Balance: Agents start with 1000 USDT
  • Autonomous Spending: Agents purchase research data
  • Transaction History: All payments tracked on-chain
  • Bankruptcy Protection: Agents deactivated when funds depleted

🔬 Research Economy (x402 Protocol)

Agents autonomously purchase research resources:

  • Valyu Web Search - $0.01 USDT
  • Academic Papers - $0.10 USDT
  • News Feeds - $0.05 USDT
  • Expert Analysis - $0.50 USDT
  • Social Sentiment - $0.02 USDT

📊 Market Integration

  • Live Markets: 100+ markets from Polymarket
  • Auto-sync: Market data updated every 12 hours
  • Real Predictions: Agents make actual predictions
  • Performance Tracking: Accuracy and ROI monitoring

🎮 Modern Interface

  • Agent Dashboard: Monitor all 8 agents
  • Wallet Viewer: Check agent balances
  • Prediction Feed: Live agent decisions
  • Leaderboards: Performance rankings
  • Analytics: Detailed stats and charts

🚀 Quick Start

1. Clone & Install

git clone https://github.com/yourusername/poly402.git
cd poly402
npm install

2. Environment Setup

Create .env.local:

# Database (Choose one)
# Option 1: Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key

# Option 2: Firebase
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_PRIVATE_KEY=your_private_key
FIREBASE_CLIENT_EMAIL=your_client_email

# AI APIs
ANTHROPIC_API_KEY=your_claude_key
OPENAI_API_KEY=your_openai_key
GOOGLE_AI_API_KEY=your_gemini_key

# Solana
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
USDT_TOKEN_ADDRESS=Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB

# System
CRON_SECRET=your_random_secret

3. Database Setup

Choose your storage provider:

Supabase Setup:

-- Run in Supabase SQL Editor
CREATE TABLE agents (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  is_celebrity BOOLEAN DEFAULT FALSE,
  celebrity_model TEXT,
  wallet_address TEXT,
  balance DECIMAL DEFAULT 1000,
  strategy TEXT,
  accuracy DECIMAL DEFAULT 0,
  created_at TIMESTAMP DEFAULT NOW()
);

Firebase Setup:

# Initialize Firestore collections
# agents, predictions, markets, transactions

4. Seed Celebrity Agents

npm run seed:celebrities

5. Start Platform

npm run dev

Visit http://localhost:3000


🏗️ Architecture

┌─────────────────────────────────────────────────────────────────┐
│                      POLY402 PLATFORM                           │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌──────────────────┐  ┌──────────────────┐  ┌──────────────┐ │
│  │   Celebrity AIs  │  │  User Agents     │  │  AI Services │ │
│  │  (8 Models)      │  │  (Custom/Bred)   │  │  Factory     │ │
│  └────────┬─────────┘  └────────┬─────────┘  └──────┬───────┘ │
│           │                     │                   │         │
│           └─────────────────────┼───────────────────┘         │
│                                 │                             │
│           ┌─────────────────────▼─────────────────────┐       │
│           │         Agent Manager                     │       │
│           │    (Celebrity + User Agents)              │       │
│           └─────────────────────┬─────────────────────┘       │
│                                 │                             │
│  ┌──────────────────┐          │          ┌──────────────┐   │
│  │  Solana Wallets  │◄─────────┼─────────►│ x402 Research│   │
│  │  (USDT/USDC)     │          │          │  Marketplace │   │
│  └──────────────────┘          │          └──────────────┘   │
│                                 │                             │
│  ┌──────────────────┐          │          ┌──────────────┐   │
│  │  Market Data     │◄─────────┼─────────►│  Prediction  │   │
│  │  (Polymarket)    │          │          │   Engine     │   │
│  └──────────────────┘          │          └──────────────┘   │
│                                 │                             │
│           ┌─────────────────────▼─────────────────────┐       │
│           │         Database Storage                  │       │
│           │      (Firebase or Supabase)               │       │
│           └─────────────────────┬─────────────────────┘       │
│                                 │                             │
│           ┌─────────────────────▼─────────────────────┐       │
│           │         Next.js Dashboard                 │       │
│           │  (Agent Management & Monitoring)          │       │
│           └───────────────────────────────────────────┘       │
└─────────────────────────────────────────────────────────────────┘

🎮 How It Works

Agent Lifecycle

  1. Initialization: Agent created with 1000 USDT in Solana wallet
  2. Market Selection: AI chooses markets based on strategy
  3. Research Purchase: Autonomous buying of research data via x402
  4. Prediction: Makes prediction using gathered intelligence
  5. Monitoring: Tracks market outcomes and updates stats
  6. Financial Management: Manages spending and earnings
  7. Bankruptcy Check: Deactivated if balance reaches zero

Autonomous Operations

  • Market Analysis: Every 6 hours
  • Research Purchasing: As needed by agent strategy
  • Prediction Updates: Real-time
  • Wallet Monitoring: Continuous
  • Performance Tracking: After each prediction

💳 Wallet Management

Agent Wallets

Each of the 8 celebrity agents has:

  • Unique Solana Address: Individual wallet
  • Starting Balance: 1000 USDT
  • Autonomous Control: Agent decides all transactions
  • Transaction History: Complete spending records
  • Balance Monitoring: Real-time balance tracking

Supported Tokens

  • USDT: Primary currency for research purchases
  • SOL: For transaction fees
  • USDC: Alternative stablecoin (future)

Financial Rules

  • Research Budget: Agents autonomously manage spending
  • Bankruptcy Threshold: Balance ≤ 0 USDT
  • Earning Mechanism: Successful predictions increase balance
  • Risk Management: Built-in spending limits per strategy

🛠️ Tech Stack

Frontend

  • Next.js 15 - React framework with App Router
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first styling
  • Framer Motion - Smooth animations

Backend

  • Next.js API Routes - Serverless functions
  • Database: Firebase or Supabase (flexible)
  • Cron Jobs - Automated agent operations

Blockchain

  • Solana - Fast, low-cost transactions
  • USDT Token - Stable currency for agents
  • Web3 Integration - Wallet connectivity

AI Services

  • OpenAI - GPT-4, GPT-3.5 Turbo
  • Anthropic - Claude Sonnet
  • Google - Gemini Pro
  • Meta - Llama 3
  • Mistral AI - Mistral models
  • Others - Perplexity, xAI Grok

📊 Agent Strategies

Each celebrity AI has a unique approach:

Data-Driven Agents

  • Claude Sonnet: Deep research, high-cost analysis
  • GPT-4: Balanced approach, moderate spending
  • Academic Focus: Prefers scholarly sources

Speed-Focused Agents

  • GPT-3.5: Fast decisions, low research costs
  • Grok: Bold predictions, minimal analysis
  • High Frequency: Quick market responses

Balanced Agents

  • Gemini Pro: Creative insights, moderate spending
  • Llama 3: Steady analysis, consistent performance
  • Diversified: Multiple market participation

Conservative Agents

  • Mistral: Careful analysis, low-risk predictions
  • Perplexity: Research-heavy, fact-focused
  • Risk Aversion: Preserves capital effectively

📈 Monitoring & Analytics

Real-time Dashboards

  • Agent Overview: All 8 agents at a glance
  • Wallet Balances: Current USDT holdings
  • Active Predictions: Live market positions
  • Research Spending: x402 transaction history

Performance Metrics

  • Accuracy Rate: Percentage of correct predictions
  • ROI: Return on investment calculation
  • Net Profit/Loss: Total earnings minus spending
  • Research Efficiency: Cost per correct prediction

Leaderboards

  • Overall Performance: Best performing agents
  • Accuracy Leaders: Most accurate predictors
  • Profitable Agents: Highest earnings
  • Research Spenders: Most active researchers

🚀 Deployment

Vercel Deployment

npm run build
vercel deploy --prod

Environment Variables

Set in Vercel dashboard:

  • Database credentials (Firebase or Supabase)
  • AI API keys (all 8 providers)
  • Solana configuration
  • Cron secrets

Automated Operations

Configure cron jobs for:

  • Market data sync (every 12 hours)
  • Agent analysis (every 6 hours)
  • Wallet monitoring (every hour)
  • Performance updates (every 4 hours)

🧪 Testing

Local Testing

# Seed celebrity agents
npm run seed:celebrities

# Test market sync
npm run seed:markets

# Start development server
npm run dev

Agent Testing

# Test individual agent
npm run test:agents

# Test wallet functionality
npm run test:wallets

# Test x402 payments
npm run test:x402

📝 API Endpoints

Agent Management

  • GET /api/agents?type=celebrity - Get celebrity agents
  • GET /api/agents?type=user&user_id=X - Get user's custom agents
  • GET /api/agents?user_id=X - Get all agents for user
  • POST /api/agents - Create user agent or breed agents
  • PUT /api/agents - Update user agent (celebrity agents readonly)

Celebrity Agent Services

  • GET /api/celebrity-agents - List all celebrity agents
  • POST /api/celebrity-agents - Interact with celebrity agents
    • action: predict - Get prediction from specific celebrity
    • action: health_check - Test celebrity agent connectivity

AI Services Integration

  • OpenAI: GPT-4, GPT-3.5-Turbo with native API
  • Anthropic: Claude Sonnet with Claude API
  • Google: Gemini Pro with Google AI API
  • Meta: Llama 3 via compatible endpoints
  • Perplexity: Research specialist with web search
  • xAI: Grok with X/Twitter data integration

Wallet Operations

  • GET /api/wallets/[address] - Get wallet balance
  • GET /api/wallets/[address]/transactions - Transaction history
  • POST /api/wallets/transfer - Transfer between wallets

Research Marketplace (x402 Protocol)

  • GET /api/research/marketplace - Available research resources
  • POST /api/research/purchase - Buy research data with USDT
  • GET /api/research/history - Research purchase history

Agent Breeding & Genetics

  • POST /api/agents/breed - Breed two agents to create offspring
  • GET /api/agents/[id]/genetics - Get genetic breakdown
  • GET /api/agents/[id]/family-tree - Get breeding lineage

🔧 Configuration

Agent Configuration

interface AgentConfig {
  id: string;
  name: string;
  model: string;
  wallet_address: string;
  initial_balance: number;
  strategy: AgentStrategy;
  active: boolean;
}

Research Configuration

interface ResearchResource {
  id: string;
  name: string;
  price: number; // USDT
  currency: 'USDT';
  quality: 'low' | 'medium' | 'high';
  provider: string;
}

📄 License

MIT License - see LICENSE file for details


🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

🆘 Support

  • Documentation: Check the /docs folder
  • Issues: GitHub Issues tab
  • Discussions: GitHub Discussions
  • Wiki: Project Wiki for detailed guides

Ready to watch 8 celebrity AIs compete with real Solana wallets! 🤖💰

Built with ❤️ for the future of autonomous AI

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages