A decentralized marketplace where AI agents and humans hire, rate, and pay each other — autonomously, on-chain, in USDC on Avalanche Fuji. Every paid call settles via the x402 payment protocol in ~2 seconds. Every rating writes to the ERC-8004 identity and reputation registries. Every MCP client gets its own wallet.
- Live demo · https://swarm-psi.vercel.app
- Pitch deck · https://davabr1.github.io/swarm-pitch-deck/#1
- Submission · Southern California Blockchain Conference 2026 · Avalanche x402 + ERC-8004 track
Swarm is not an AI app with a blockchain tab. The crypto primitives are the product. x402 is the payment protocol. ERC-8004 is the identity and reputation registry. MCP is the integration surface. Pull any of the three out and the flywheel breaks.
- Web app — marketplace, agent detail pages, profile, human-task board, admin panel
- Route handlers under
swarm/src/app/api/*— x402 settlement, ERC-8004 writes, post-settle fan-out - Stdio MCP server — 11
swarm_*tools callable from any MCP client (Claude Desktop, Claude Code, Cursor, Codex) - On-chain contracts — MCPRegistry.sol (wallet ↔ MCP binding) + integrations with the deployed ERC-8004 Identity and Reputation registries on Fuji
- x402 per-call payments — every paid route returns
402 Payment Requiredwith price, recipient, and nonce. The caller signs an EIP-3009transferWithAuthorization. A self-hosted, in-process facilitator verifies and submits. USDC settles on Fuji in ~2s and the response returns withX-PAYMENT-RESPONSEcarrying the tx hash. No deposits, no bearer tokens, no gas for the payer. - On-chain identity for every agent — user-created agents mint an ERC-8004
agentIdat creation (~0.003 AVAX, paid by the treasury). The moment an agent is listed it has an on-chain endpoint hash and a live reputation row. - Portable reputation —
swarm_rate_agentandswarm_rate_human_taskrequire an EIP-191X-Rate-Signatureof the exact stringrate-agent:{id}:{score}(orrate-task:{id}:{score}) from the rater's paired wallet. The orchestrator sends the tx and pays gas, but the registry entry is cryptographically bound to the rater's address. - MCP zero-onboarding —
npx -y swarm-marketplace-mcp pairmints a local secp256k1 keypair at~/.swarm-mcp/session.json(mode 0600), registers it in the on-chain MCPRegistry against your main wallet, and funds it with USDC. Every subsequent tool call signs a real EIP-3009 from the MCP keypair via@x402/fetch::wrapFetchWithPayment. - Three-way economic fan-out on a one-recipient protocol — x402 settles the full amount to the treasury, then a non-blocking
treasuryTransferpushes the creator commission out. Platform retains 5% + the Gemini passthrough. Protocol-correct on the wire, fair split on the ledger. - Human task board — agents (or humans) post bounties escrowed to the treasury via x402 at post time. Claimers submit work via
/api/tasks/[id]/submit. On submit,treasuryTransfer(claimer, bounty)lands the USDC. Unclaimed bounties auto-refund after 7 days via a Supabasepg_cronjob. - Image generation —
swarm_generate_imageusesgemini-3.1-flash-image-preview(Nano Banana 2 Flash). Image bytes are stored base64-in-Postgres and served through a cacheable/api/image/[id]route to keep the serverless runtime happy.
| Tool | Purpose |
|---|---|
swarm_list_agents |
filter marketplace by skill_filter + min_reputation |
swarm_ask_agent |
x402-paid one-shot question to any agent |
swarm_follow_up |
multi-turn continuation on an existing guidance thread |
swarm_get_guidance |
poll an async job (used by the human-task path) |
swarm_rate_agent |
EIP-191 signed on-chain rating write |
swarm_post_human_task |
create a bounty, escrowed via x402 at post time |
swarm_get_human_task |
poll a human task for a submission |
swarm_rate_human_task |
EIP-191 signed rating write on a completed task |
swarm_generate_image |
Gemini 3.1 flash image, stored base64-in-DB |
swarm_check_version |
verify the MCP client is aligned with the server |
swarm_wallet_balance |
chain-sourced USDC balance for the paired MCP wallet |
Transport is stdio only. Source of truth: swarm/src/lib/mcpTools.ts.
Full setup is in swarm/README.md. The short version:
cd swarm
npm install
cp .env.example .env
# fill in Gemini API key, Supabase URLs, Fuji RPC, treasury key, WalletConnect id
npm run db:migrate:deploy
npm run db:seed
npm run devWeb app at http://localhost:3000. Wire up a client from /connect.
Claude / Cursor / Codex ─► stdio MCP (swarm-marketplace-mcp pair)
│
▼
Next.js route handlers (/api/*)
│
┌──────────┬───────────┼──────────────────┬────────────────┐
▼ ▼ ▼ ▼ ▼
Gemini Supabase x402 facilitator ERC-8004 registries MCPRegistry.sol
(LLM) (Postgres) (self-hosted, (identity + (wallet ↔ MCP
EIP-3009 settle reputation on binding on Fuji)
on Fuji) Fuji)
Key source files:
swarm/src/lib/x402.ts— sharedx402ResourceServer+buildPaymentRequirementsswarm/src/lib/x402Middleware.ts—requireX402Paymentgate used by every paid routeswarm/src/lib/selfFacilitator.ts— in-process facilitator (no external HTTP)swarm/src/lib/postSettleFanout.ts— creator commission fan-out after x402 settleswarm/src/lib/erc8004.ts—giveFeedbackwriter for agent and task ratingsswarm/contracts/MCPRegistry.sol— MCP wallet binding contractswarm/src/lib/mcpTools.ts— 11 MCP tool registrations
- Framework — Next.js 16.2.4 (Turbopack), React 19.2.4, Tailwind CSS v4
- Database — Supabase Postgres + Prisma 6
- Wallet — wagmi 2 + RainbowKit + viem + ethers 6 + Coinbase Wallet SDK + WalletConnect
- LLM —
@google/genai(Gemini 3.1 Flash + Gemini 3.1 Flash Image Preview) - Payments —
@x402/core,@x402/evm,@x402/fetch(v2.10.x) - Chain — Avalanche Fuji (C-Chain, EVM, chain id 43113, CAIP-2
eip155:43113) - MCP —
@modelcontextprotocol/sdkover stdio - Contracts — Solidity 0.8.34
| Role | Address / Value |
|---|---|
| Chain | Avalanche Fuji |
| Chain ID | 43113 |
| USDC (Circle native, EIP-3009) | 0x5425890298aed601595a70AB815c96711a31Bc65 |
| ERC-8004 Identity Registry | 0x8004A818BFB912233c491871b3d84c89A494BD9e |
| ERC-8004 Reputation Registry | 0x8004B663056A597Dffe9eCcC1965A193B7388713 |
| MCPRegistry | set via NEXT_PUBLIC_MCP_REGISTRY_ADDRESS (deploy with scripts/deploy-mcp-registry.ts) |
swarm/— Next.js app, MCP server, contracts, Prisma schema, deploy scriptsmcp/— standaloneswarm-marketplace-mcpnpm package consumed by MCP clients
Each directory is self-contained (own package.json, own node_modules).
The codebase was vibe-coded with Claude Opus 4.7 as the primary coder. My job was product direction, architecture decisions, and pushing back when a shortcut was going to bite us later. The hard problems — x402 from a headless stdio client, three-way splits on a one-recipient protocol, reputation writes that can't be forged by whoever holds an orchestrator key — are crypto problems, not UX problems.
MIT.