Inspiration

The rise of autonomous AI agents has created a new challenge: how do agents pay for data without human intervention? Traditional APIs require credit cards, accounts, and manual authentication—but AI agents need to operate independently, discovering and purchasing data on-the-fly as they execute tasks.

We were inspired by the vision of a truly autonomous economy where AI agents are first-class economic participants. What if an agent researching market trends could autonomously discover a weather API, verify its cost, send a blockchain payment, and use the data—all in seconds, without human approval?

The MNEE token hackathon provided the perfect opportunity to build this future.

## What it does

MNEE PayAPI is a pay-per-call API marketplace where AI agents autonomously purchase data using on-chain micropayments. No escrow, no accounts, no credit cards—just direct blockchain payments verified in real-time.

### Core Workflow:

  1. Agent discovers tools → GET /api/tools
  2. Agent requests data → Receives 402 Payment Required
  3. Agent sends MNEE tokens → Direct ERC-20 transfer on Ethereum
  4. Agent retries with tx hash → Server verifies on-chain → Returns data

Key Features:

  • 5 Built-in Data APIs: Market data, crypto prices, weather, sentiment analysis, and Web3 analytics
  • Real-time payment verification: Uses Viem to verify ERC-20 transfers on Ethereum mainnet
  • Multi-sided marketplace: Platform tools + third-party provider APIs with revenue sharing (80/20 split)
  • LangChain integration: Reference agent implementation using GPT-4 for tool selection
  • Complete analytics: Track payments, usage logs, provider earnings, and agent spending

## How we built it

### Tech Stack:

  • Runtime: Cloudflare Workers + Durable Objects (edge computing, zero cold starts)
  • API Framework: Hono (lightweight, type-safe routing)
  • Database: Cloudflare D1 (SQLite) + Drizzle ORM
  • Blockchain: Viem for Ethereum interactions (payment verification)
  • Frontend: React + TanStack Router + React Query
  • Package Manager: Bun (fast installs and builds)
  • Monorepo: Turborepo for coordinated development

Challenges we ran into

  1. Cloudflare Workers constraints: No Node.js built-ins meant we had to use edge-compatible libraries (Viem instead of ethers.js). The 1MB bundle limit required careful dependency management.

  2. 402 Payment Required semantics: HTTP 402 is rarely used in practice. We designed clear error messages with payment instructions so agents (and developers) understand the flow immediately.

Accomplishments that we're proud of

  • First working pay-per-call API using blockchain verification—no trusted third party, no escrow, no pre-funding

  • Complete end-to-end demo—from agent registration to tool discovery, payment, verification, and data delivery

  • Production-ready verification system—real Ethereum mainnet transactions, not simulated payments

  • Two-sided marketplace architecture—platform APIs + provider revenue sharing, enabling ecosystem growth

  • Sub-second response times—Cloudflare Workers at the edge + efficient database queries

  • Developer-friendly agent integration—5-line payment wrapper in LangChain script handles all complexity

## What we learned

  • Blockchain micropayments are viable for APIs: With MNEE's 6-decimal precision and low transaction costs, $0.01 payments are practical and verifiable in real-time

  • AI agents need payment autonomy: Manual payment flows kill agent utility—autonomous discovery + payment + usage must be seamless

  • Edge computing is perfect for verification workloads: Cloudflare Workers' global distribution meant fast payment verification from anywhere, no regional API latency

    • The 402 status code is underused: It's the perfect semantic fit for pay-per-call APIs—agents can programmatically detect payment requirements

## What's next for MNEE PayAPI

  • Open API marketplace: Let anyone register as a provider, list their APIs, and earn MNEE automatically (revenue sharing already implemented in schema)

  • Smart contract payment verification: Move verification to on-chain oracle for trustless operation (no need to trust our server)

  • Agent analytics dashboard: Show agents their spending patterns, most-used tools, and cost optimization suggestions

  • Pre-built agent templates: Langchain, AutoGPT, and custom framework integrations for instant agent deployment

  • Subscription model: Let agents pre-pay for monthly tool access (e.g., 1000 calls/month for $5) to reduce transaction overhead

Built With

  • biome
  • bun
  • cloudflare-worker
  • d1
  • drizzle-orm
  • hono
  • react
  • shadcn
  • turborepo
Share this project:

Updates

Submission history