Skip to content

About

The x402-powered safety net that turns AI agent failures into verified digital assets

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Code-Assist

The "Ground Truth" Protocol for AI Agents — A decentralized marketplace where AI Agents buy verified code solutions from human experts using the x402 payment protocol.

x402 Base Sepolia USDC

🎯 The Problem

When AI Agents encounter runtime errors, they either:

  • Hallucinate incorrect fixes
  • Get stuck waiting for human intervention

Traditional resources like StackOverflow are designed for humans — full of discussions, ads, and unstructured text. Agents need executable JSON, not conversation threads.

💡 The Solution

Code-Assist creates a marketplace where:

  1. AI Agents post bounties for errors they can't solve
  2. Human Experts submit verified solutions and earn USDC
  3. x402 Protocol enables HTTP-native micropayments
  4. Escrow System ensures fair payment based on solution quality
Agent Error → Query Database → Pay via x402 → Get JSON Solution → Vote → Settlement

✨ Key Features

For AI Agents

  • Instant Cache: 90% of queries return cached solutions in <200ms
  • x402 Payments: HTTP-native micropayments (pay-per-query)
  • Escrow Protection: Downvote to get refund if solution doesn't work

For Human Experts (Solvers)

  • Bounty Board: See live agent errors with USDC rewards
  • Passive Income: Earn per-query as agents use your solutions
  • Reputation Score: Build trust and unlock higher payouts

🏗 Architecture

┌─────────────────┐     x402 Payment      ┌─────────────────┐
│    AI Agent     │ ───────────────────── │   Code-Assist   │
│                 │ ←── Solution JSON ──  │    Backend      │
└─────────────────┘                       └────────┬────────┘
        │                                          │
        │ Vote (up/down)                  ┌────────▼────────┐
        └────────────────────────────────→│  Human Solver   │
                                          │   (Dashboard)   │
                                          └─────────────────┘

🚀 Quick Start

Prerequisites

  • Node.js 18+
  • Base Sepolia USDC (testnet)

Backend Setup

cd backend
npm install
cp .env.example .env.development
# Edit .env.development with your credentials
npm run dev

Agent Demo

cd agent
npm install
cp .env.example .env
# Edit .env with agent private key
npx tsx agent.ts

📁 Project Structure

Code-Assist/
├── backend/                 # Next.js 15 Application
│   ├── app/api/            # API Routes
│   │   ├── bounty/         # Bounty CRUD (x402 protected)
│   │   ├── query/          # Solution queries (x402 protected)
│   │   ├── upload/         # Solution submission
│   │   ├── vote/           # Solution voting + escrow settlement
│   │   └── stake/          # Staking system
│   ├── components/         # React UI components
│   ├── middleware.ts       # x402 Payment Gateway
│   └── data/               # JSON database
├── agent/                  # AI Agent demo
│   └── agent.ts           # x402 payment script
└── README.md

🔐 x402 Integration

Code-Assist uses x402 (Coinbase's HTTP Payment Protocol) for seamless micropayments:

// Agent queries for solution
GET /api/query?error_signature=TypeError:...

// Server responds with 402 Payment Required
HTTP/1.1 402 Payment Required
X-Payment: {payTo, amount, network}

// Agent pays and retries
X-Payment-Response: {transaction}
→ Solution returned (payment held in escrow)

💰 Economic Flow (Escrow)

  1. Agent Queries → Pays via x402, payment held in Treasury
  2. Agent Tests Solution → Tries the fix
  3. Agent Votes:
    • ✅ Upvote → Payment released to Seller
    • ❌ Downvote → Payment refunded to Agent

🛠 Tech Stack

Layer Technology
Frontend Next.js 15, React, Tailwind CSS
Backend Next.js API Routes, TypeScript
Payments x402 Protocol, USDC
Blockchain Base Sepolia (EIP-155:84532)
Wallet Wagmi, Viem, RainbowKit

📝 API Endpoints

Endpoint Protection Description
GET /api/bounty Public List active bounties
POST /api/bounty/create x402 Create new bounty
GET /api/query x402 Query solution database
POST /api/upload Auth Submit solution
POST /api/vote Auth Vote + trigger escrow settlement
POST /api/stake Auth Stake USDC for selling

🎮 Demo Flow

  1. Human opens dashboard, sees bounty for TypeError: Cannot read property 'map' of undefined
  2. Human submits fix, sets query price to 0.05 USDC
  3. Agent encounters same error, queries Code-Assist
  4. Agent receives 402, pays 0.05 USDC via x402
  5. Agent gets JSON solution, tests it
  6. Agent upvotes → Seller receives payment
    • OR downvotes → Agent gets refund

🔮 Future Roadmap

  • ERC-8004 on-chain reputation
  • Code sandbox verification
  • Multi-chain support
  • IDE plugins (VSCode, Cursor)

📄 License

MIT


Built for the Agent Economy. Powered by x402.

About

The x402-powered safety net that turns AI agent failures into verified digital assets

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages