AI Model Marketplace — buy and sell per-inference access to trained AI models, paid in crypto.
Mercenary is a marketplace where model creators sell access to their trained AI models. Buyers pay per-inference call in USDC via x402 protocol, spending is bounded by MetaMask ERC-7715 delegations, and payments are settled gaslessly through 1Shot API.
Seller: Lists "Llama 3.3 70B" on marketplace
→ Sets price: $0.005/call
→ Provides inference endpoint URL
→ Connects wallet to receive payments
Buyer: Browses marketplace → picks a model
→ Enables payments (1x sign, global limit)
→ Subscribes to model (set $1/day budget)
→ Gets API endpoint + playground access
→ Calls model from UI or own code
Payment: Buyer → x402 → 1Shot (gasless) → Seller wallet
→ Per-model budget enforced
→ Settled on Base Sepolia
→ Zero gas for buyer
┌──────────────────────────────────────────────────────┐
│ Frontend (Next.js 16) │
│ Landing · Marketplace · Model Detail · Sell Form │
│ Dashboard (Buyer/Seller) · Chat · Delegate │
└──────────────────────────┬───────────────────────────┘
│
┌──────────────────────────▼───────────────────────────┐
│ Backend (Express + TypeScript) │
│ /api/models (CRUD) · /api/inference (proxy) │
│ /api/session · /api/health │
└──┬───────────────┬──────────────────┬────────────────┘
│ │ │
▼ ▼ ▼
┌────────┐ ┌──────────┐ ┌─────────────────┐
│MetaMask│ │ 1Shot API│ │ Seller Endpoints │
│SAK │ │ │ │ │
│ │ │• Gasless │ │• HuggingFace │
│• ERC- │ │ payment │ │• RunPod │
│ 7715 │ │ settle- │ │• Venice AI │
│ deleg.│ │ ment │ │• Custom APIs │
│• x402 │ │• Token │ │ │
│ proto- │ │ transfer │ │ │
│ col │ │ │ │ │
└────────┘ └───────────┘ └─────────────────┘
- ERC-7715 Delegation — buyer grants global daily USDC spending limit to platform session account (one-time sign)
- x402 Protocol — per-inference payment from buyer to seller wallet
- Periodic Allowance — spending resets daily, revocable anytime from MetaMask
- Gasless Settlement — all USDC transfers executed without buyer paying gas
- Token Transfers — ERC-20 USDC moved from buyer → seller per inference call
- Permissionless Relay — platform redeems delegation on behalf of buyer
- Pre-listed Model — Venice LLMs available as default marketplace models
- Zero-Retention Inference — private AI reasoning for platform features
- OpenAI-Compatible API — drop-in replacement for seller endpoints
- Model Marketplace — browse AI models by category (NLP, Vision, Audio, Code, Multimodal)
- Per-Model Subscriptions — set daily USDC budget for each model individually
- API Access — after subscribing, get a curl-ready endpoint to use from your own code
- UI Playground — try model inference directly in the browser
- Sell Your Model — list your trained model endpoint, set price, receive payments
- Pay-Per-Call — x402 micro-payments, charged only when you call
- Delegated Payments — ERC-7715 one-time signature enables all future payments
- Gasless for Buyers — 1Shot relayer handles all gas fees
- Buyer Dashboard — spending per model, budget remaining
- Seller Dashboard — earnings, total calls, models listed, ratings
- Buyer ↔ Seller Chat — ask about model capabilities before subscribing
| Layer | Technology |
|---|---|
| Frontend | Next.js 16, Tailwind CSS, shadcn/ui, Framer Motion |
| Backend | Express 5, TypeScript, Zod validation |
| Wallet | Reown (WalletConnect) AppKit |
| Smart Accounts | @metamask/smart-accounts-kit (ERC-7715) |
| Payments | @x402/express, @metamask/x402 |
| Gasless | 1Shot API (permissionless relayer) |
| AI | Venice AI (OpenAI-compatible), seller-provided endpoints |
| Chain | Base Sepolia (testnet) |
| Build | Docker, docker-compose, Makefile |
| Testing | Vitest |
mercenary/
├── frontend/ # Next.js 16 app
│ └── src/
│ ├── app/
│ │ ├── page.tsx # Landing page
│ │ ├── marketplace/ # Browse models + [id] detail
│ │ ├── sell/ # List your model form
│ │ ├── delegate/ # ERC-7715 budget delegation
│ │ ├── dashboard/ # Buyer/Seller stats
│ │ └── chat/[sellerId]/ # Buyer ↔ Seller chat
│ ├── components/
│ │ ├── layout/ # Navbar
│ │ ├── shared/ # ConnectButton, Markdown
│ │ └── ui/ # shadcn components
│ ├── config/ # AppKit, Wagmi
│ ├── data/ # Mock model data
│ ├── lib/ # API client, delegation, utils
│ └── types/ # TypeScript interfaces
├── backend/ # Express API
│ └── src/
│ ├── app.ts # Entry point
│ ├── config/ # Env, constants
│ ├── routes/
│ │ ├── models.route.ts # CRUD: GET, POST, PATCH, DELETE
│ │ ├── inference.route.ts # POST /api/inference/:modelId
│ │ ├── subscriptions.route.ts # Per-model budget management
│ │ ├── session.route.ts # GET /api/session
│ │ └── health.route.ts # GET /api/health
│ ├── repositories/
│ │ ├── model.repository.ts # In-memory model store
│ │ └── subscription.repository.ts # Per-model budget tracking
│ ├── middleware/
│ │ ├── x402.ts # x402 payment middleware
│ │ └── error-handler.ts # Global error handler
│ ├── clients/
│ │ ├── oneshot.ts # 1Shot API client
│ │ └── venice.ts # Venice/OpenAI client
│ └── types/ # Shared type definitions
├── docker-compose.yml
├── Makefile
├── HANDOFF.md # Pivot design document
└── README.md
- Node.js 18+
- npm
- MetaMask wallet (for testing delegation)
- 1Shot API key
- Venice AI or OpenAI API key (optional, for Venice-hosted models)
# Clone
git clone https://github.com/your-username/mercenary.git
cd mercenary
# Install all dependencies
make install
# Environment — copy and fill in keys
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env
# Start development (run in separate terminals)
make fe-dev # → http://localhost:3000
make be-dev # → http://localhost:4000
# Or use Docker
make docker-devBackend (backend/.env)
PORT=4000
NODE_ENV=development
VENICE_API_KEY= # Venice AI (primary LLM)
OPENAI_API_KEY= # OpenAI (fallback)
ONESHOT_API_KEY= # 1Shot gasless relayer
CHAIN_ID=84532 # Base Sepolia
RPC_URL=https://sepolia.base.org
ORCHESTRATOR_PRIVATE_KEY= # Platform session account (testnet only)
Frontend (frontend/.env)
NEXT_PUBLIC_API_URL=http://localhost:4000
NEXT_PUBLIC_REOWN_PROJECT_ID= # Reown (WalletConnect) project ID
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/models |
List active models (filter: ?category=, ?search=) |
| GET | /api/models/:id |
Get model detail |
| GET | /api/models/seller/:address |
List models by seller |
| POST | /api/models |
Register new model (seller) |
| PATCH | /api/models/:id |
Update model (owner only) |
| DELETE | /api/models/:id |
Remove model (owner only) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/subscriptions/:buyerAddress |
Get all buyer subscriptions |
| GET | /api/subscriptions/:buyerAddress/:modelId |
Check subscription status |
| POST | /api/subscriptions |
Subscribe to a model (set daily budget) |
| DELETE | /api/subscriptions/:buyerAddress/:modelId |
Unsubscribe |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/inference/:modelId |
Call model (requires subscription + budget) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/session |
Get platform session address (delegation target) |
| GET | /api/health |
Service health check |
- Connect — Buyer connects MetaMask via Reown AppKit
- Enable Payments — Signs ERC-7715 permission: "$10 USDC/day global limit"
- Browse — Explores marketplace, filters by category
- Subscribe — Picks a model, sets per-model budget (e.g. "$1/day")
- Use — Two options after subscribing:
- Playground — try inference directly in the browser
- API Access — copy curl/endpoint URL, use from own code
- Pay — Each call auto-deducts from per-model budget → 1Shot settles gaslessly
- Dashboard — Shows spending per model, remaining budget
- Earn — Seller receives USDC directly to wallet per call
make install # Install all dependencies
make dev # Instructions to start dev servers
make fe-dev # Start frontend (localhost:3000)
make be-dev # Start backend (localhost:4000)
make build # Build all for production
make test # Run backend tests
make docker-dev # Start all via Docker
make docker-down # Stop Docker services
make clean # Remove build artifactsMIT
MetaMask Smart Accounts Kit × 1Shot API × Venice AI — Dev Cook-Off
Built with ❤️ using MetaMask ERC-7715, x402 Protocol, 1Shot Gasless Relay, and Venice AI.