0xstoa
Programmable marketplace for APIs & AI services. Turn any HTTPS endpoint into a paid service. Powered by x402 payments.
Ask AI about 0xstoa
Powered by Claude Β· Grounded in docs
I know everything about 0xstoa. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Stoa
A decentralized AI services marketplace with on-chain USDC payments
Discover, call, and pay for AI/ML services β directly from Claude Desktop, Cursor, or any MCP client. Providers register endpoints. Consumers pay per-call in USDC. Payments settle on-chain via the x402 protocol.
Β Table of ContentsΒ
Β
- What is Stoa
- Architecture
- Monorepo Structure
- Tech Stack
- Live Deployments
- How It Works
- Database Schema
- API Reference
- Getting Started
- Environment Variables
- Deployment
- Team
Β
What is Stoa
Stoa is a full-stack AI services marketplace where:
- Providers register ML models, AI agents, or API tools β set a price in USDC, and earn per call
- Consumers discover services via semantic search, call them, and pay automatically on-chain
- AI assistants (Claude, Cursor) interact with the marketplace natively through MCP tools β search, call, and pay without leaving the conversation
The entire payment layer runs on Base Sepolia using the x402 HTTP payment protocol β no smart contract deployment needed. Services are discoverable via pgvector semantic search powered by HuggingFace embeddings.
Architecture
C O N S U M E R S
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Web App β β Claude β β Agent SDK β
β (Next.js) β β Desktop β β (TypeScript)β
ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ
β β β
β ββββββββ΄ββββββββ β
β β MCP Server β β
β β (16+ tools) β β
β ββββββββ¬ββββββββ β
β β β
βΌ βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β S T O A A P I (Hono) β
β β
β ββββββββββ ββββββββββββ ββββββββββ ββββββββββ β
β β Auth β β Services β β Wallet β β x402 β β
β β Routes β β Routes β β Routes β β Proxy β β
β ββββββ¬ββββ ββββββ¬ββββββ ββββββ¬ββββ ββββββ¬ββββ β
β ββββββββββββββ΄ββββββββββββββ΄ββββββββββββ β
β Drizzle ORM + pgvector β
βββββββββββββββββββββββββ€βββββββββββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββββ
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββ
β Supabase β β Coinbase β β HF β
β Postgres β β CDP β β Spaces β
ββββββββββββ ββββββββββββ ββββββββββββ
Monorepo Structure
stoa/
β
βββ apps/
β βββ web/ Next.js 16 frontend
β β thirdweb wallet, Radix UI, Framer Motion
β β
β βββ mcp-server/ MCP server for Claude Desktop & Cursor
β 16+ tools: search, call, pay, manage
β
βββ packages/
β βββ server/ Hono API backend
β β auth, services, wallet, x402, razorpay
β β
β βββ db/ Drizzle ORM + pgvector
β β schema, queries, semantic search
β β
β βββ shared/ Zod schemas, TypeScript types, constants
β β
β βββ agent-sdk/ TypeScript SDK for the Stoa API
β β
β βββ contracts/ Smart contract stubs
β
βββ services/
β βββ chest-xray-service/ Pneumonia detection (ViT, HF Spaces)
β βββ plant-disease-service/ Plant disease ID (MobileNetV2, HF Spaces)
β βββ digital-twin-agent/ AI personality service (FastAPI)
β
βββ scripts/
β βββ seed-services.ts Seed marketplace with starter data
β
βββ Dockerfile Multi-stage build for Railway
βββ turbo.json Turborepo pipeline
βββ pnpm-workspace.yaml Workspace definition
Package dependency graph:
shared βββββββ
ββββΊ server βββΊ Docker βββΊ Railway
db βββββββββββ
β
mcp-server ββββββββββ€ (calls API over HTTP)
web βββββββββββββββββ€ (calls API over HTTP)
agent-sdk βββββββββββ (calls API over HTTP)
Tech Stack
| Layer | Technology |
|---|---|
| Frontend | Next.js 16 Β· React 19 Β· TailwindCSS 4 Β· Radix UI Β· Framer Motion Β· Recharts |
| Backend | Hono 4 Β· Node.js 24 Β· TypeScript 5.7 |
| Database | PostgreSQL (Supabase) Β· Drizzle ORM Β· pgvector |
| Blockchain | Base Sepolia Β· USDC Β· Viem 2 Β· Coinbase CDP SDK |
| Payments | x402 Protocol v2 Β· @x402/hono Β· @x402/fetch Β· @x402/evm |
| Wallet | thirdweb 5 (frontend) Β· Coinbase CDP (backend managed) |
| Embeddings | HuggingFace Inference Β· nomic-embed-text-v1.5 (768-dim) |
| AI Models | HuggingFace Spaces Β· FastAPI + Docker |
| MCP | @modelcontextprotocol/sdk Β· stdio + SSE transport |
| Auth | JWT Β· bcrypt Β· API keys Β· Google OAuth (Supabase) |
| Fiat Onramp | Razorpay (INR to USDC) |
| Monorepo | pnpm 9 Β· Turborepo 2 |
| Deployment | Railway (API) Β· Vercel (Web) Β· HuggingFace Spaces (ML) |
Live Deployments
| Service | URL | Status |
|---|---|---|
| API Backend | https://stoa-api-production-58bd.up.railway.app | Railway |
| Health Check | https://stoa-api-production-58bd.up.railway.app/health | GET |
| Chest X-ray Model | https://hiteshx33-chest-xray-service.hf.space | HF Spaces |
| Plant Disease Model | https://hiteshx33-plant-disease-service.hf.space | HF Spaces |
| Database | Supabase PostgreSQL + pgvector | Supabase |
| Blockchain | Base Sepolia Β· Chain ID 84532 | Testnet |
| USDC Contract | 0x036CbD53842c5426634e7929541eC2318f3dCF7e | Base Sepolia |
How It Works
Service Discovery
Services are registered with metadata, capabilities, and pricing. Each service gets a 768-dimensional embedding (via nomic-embed-text-v1.5) stored in a pgvector column. Discovery uses cosine similarity search:
User query: "detect pneumonia from medical images"
β
βΌ
βββββββββββββββββββββββ
β Generate embedding β HuggingFace Inference API
β (768 dimensions) β
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β pgvector cosine β PostgreSQL + Drizzle
β similarity search β
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Ranked results β Sorted by match score
β with confidence β
βββββββββββββββββββββββ
Payment Flow (x402)
Consumer Stoa API Provider
β β β
β POST /v1/call/:id β β
β βββββββββββββββββββββββΊ β β
β β β
β 402 + PAYMENT-REQUIRED β β
β βββββββββββββββββββββββ β β
β β β
β Same request + β β
β PAYMENT-SIGNATURE header β β
β βββββββββββββββββββββββΊ β β
β β Forward to endpoint β
β β βββββββββββββββββββββββΊ β
β β β
β β Result β
β β βββββββββββββββββββββββ β
β β β
β Result + txHash + β Settle on-chain (async) β
β basescanUrl β β
β βββββββββββββββββββββββ β β
Three payment modes:
| Mode | When | How |
|---|---|---|
| x402 (on-chain) | MCP/SDK with wallet key | USDC signed via Viem, settled on Base Sepolia |
| API Key auth | X-Stoa-Key header | Cost tracked in DB, deducted from balance |
| Free / Test | priceUsdcPerCall = 0 or ?test=true | Direct call, no payment |
Authentication
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Email / β β Google β β Wallet β
β Password β β OAuth β β (thirdweb) β
ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Stoa Auth Layer β
β β
β JWT Token ββββ User Record ββββΊ API Key β
β (session) (PostgreSQL) (X-Stoa-Key) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- JWT Bearer tokens β web sessions (
POST /api/auth/login) - API keys β SDK, MCP, and programmatic access (
X-Stoa-Keyheader) - Wallet linking β connect your own wallet or auto-provision a CDP managed wallet
MCP Integration
The MCP server exposes 16+ tools that Claude Desktop or Cursor can call natively:
| Category | Tools |
|---|---|
| Account | create_account Β· login |
| Discovery | find_service Β· list_services Β· get_service_schema Β· get_activity Β· get_provider |
| ML Inference | analyze_xray Β· analyze_plant |
| Service Calls | call_service (with automatic x402 payment) |
| Wallet | get_wallet_status Β· fund_wallet Β· withdraw Β· get_usage |
| Provider | register_service Β· my_services Β· update_service Β· deactivate_service |
Claude Desktop config:
{
"mcpServers": {
"stoa": {
"command": "npx",
"args": ["@stoa/mcp-server"],
"env": {
"STOA_API_KEY": "stoa_your_key_here",
"WALLET_PRIVATE_KEY": "0x..."
}
}
}
}
Database Schema
ββββββββββββββββββββββββ ββββββββββββββββββββββββββββ
β users β β services β
ββββββββββββββββββββββββ€ ββββββββββββββββββββββββββββ€
β id uuid PK βββββββββββ userId uuid FK β
β email unique β β id uuid PK β
β passwordHash β β ownerAddress β
β walletAddress β β name β
β cdpWalletId β β description β
β displayName β β capabilities jsonb β
β googleId β β category β
β createdAt β β serviceType β
ββββββββββββ¬βββββββββββββ β priceUsdcPerCall numeric β
β β endpointUrl β
β β embedding vector(768)β
β β totalCalls β
β β successRate β
β β isActive β
β β isVerified β
β ββββββββββββ¬ββββββββββββββββ
β β
ββββββββββ΄ββββββββββββββ βββββββββββ΄βββββββββββββββ
β api_keys β β call_logs β
ββββββββββββββββββββββββ€ ββββββββββββββββββββββββββ€
β id uuid PK β β id uuid PK β
β userId uuid FK β β serviceId uuid FK β
β keyHash sha256 β β userId uuid FK β
β keyPrefix β β callerAddress β
β label β β costUsdc β
β revokedAt β β txHash β
ββββββββββββββββββββββββ β latencyMs β
β success β
ββββββββββββββββββββββββ ββββββββββββββββββββββββββ
β topup_transactions β
ββββββββββββββββββββββββ€
β id uuid PK β
β userId uuid FK β
β amountInr β
β amountUsdc β
β razorpayOrderId β
β status β
ββββββββββββββββββββββββ
Key indexes: category, ownerAddress, isActive, serviceType, embedding (pgvector)
API Reference
Β AuthenticationΒ
Β
| Method | Endpoint | Description |
|---|---|---|
POST | /api/auth/register | Create account (email + password) β returns API key |
POST | /api/auth/login | Login β returns JWT token |
POST | /api/auth/google | Google OAuth via Supabase access token |
GET | /api/auth/me | Current user profile (JWT or API key) |
Β
Β ServicesΒ
Β
| Method | Endpoint | Description |
|---|---|---|
POST | /api/services | Register a new service |
POST | /api/services/search | Semantic search (pgvector embeddings) |
GET | /api/services | List services (filters: category, type, sort, limit, offset) |
GET | /api/services/:id | Service details + recent call logs |
PUT | /api/services/:id | Update service (owner auth required) |
DELETE | /api/services/:id | Deactivate service (owner auth required) |
POST | /api/services/:id/verify | Verify endpoint is reachable |
POST | /api/services/:id/embedding | Regenerate embedding vector |
Β
Β Service Calls (x402)Β
Β
| Method | Endpoint | Description |
|---|---|---|
POST | /v1/call/:serviceId | Call a service β x402 payment or API key auth |
Returns: { result, cost, txHash, basescanUrl, latencyMs }
Β
Β WalletΒ
Β
| Method | Endpoint | Description |
|---|---|---|
POST | /api/wallet/link | Link external wallet address |
GET | /api/wallet/balance | Current USDC balance (on-chain) |
GET | /api/wallet/address | Get or auto-create wallet address |
GET | /api/wallet/transactions | Call history with costs |
GET | /api/wallet/usage | Aggregate usage stats |
POST | /api/wallet/topup/razorpay | Create Razorpay order (INR to USDC) |
POST | /api/wallet/topup/razorpay/verify | Verify Razorpay payment |
GET | /api/wallet/topup/history | Top-up transaction history |
Β
Β Providers & ActivityΒ
Β
| Method | Endpoint | Description |
|---|---|---|
GET | /api/providers/:userId | Provider profile + stats |
GET | /api/providers/:userId/services | Provider's registered services |
GET | /api/activity | Recent marketplace activity feed |
Β
Getting Started
Prerequisites
| Requirement | Version |
|---|---|
| Node.js | >= 20 |
| pnpm | >= 9 |
| PostgreSQL | with pgvector extension |
# Enable pnpm via corepack
corepack enable && corepack prepare pnpm@latest --activate
Install & Run
# 1 β Clone the repo
git clone <repo-url> && cd stoa
# 2 β Install all dependencies
pnpm install
# 3 β Configure environment
cp .env.example .env
# Fill in all required values (see next section)
# 4 β Push database schema
pnpm --filter @stoa/db drizzle-kit push
# 5 β Seed the marketplace
pnpm seed
# 6 β Start everything
pnpm dev
| Service | Default URL |
|---|---|
| API | http://localhost:3001 |
| Web | http://localhost:3000 |
Run Individual Packages
# API server only
pnpm --filter @stoa/server dev
# Web frontend only
pnpm --filter @stoa/web dev
# MCP server (stdio mode)
cd apps/mcp-server && node dist/index.js
Environment Variables
packages/server β API Backend
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection (transaction pooler, port 6543) |
DATABASE_URL_DIRECT | Migrations | Direct connection (port 5432) |
JWT_SECRET | Yes | Secret for signing JWT tokens |
HF_TOKEN | Yes | HuggingFace API token |
HF_EMBEDDING_MODEL | β | Default: nomic-ai/nomic-embed-text-v1.5 |
EMBEDDING_DIMENSIONS | β | Default: 768 |
CDP_API_KEY_ID | Yes | Coinbase CDP API key ID |
CDP_API_KEY_SECRET | Yes | Coinbase CDP API key secret |
CDP_WALLET_SECRET | β | CDP wallet encryption secret |
X402_FACILITATOR_URL | β | Default: Coinbase facilitator |
RAZORPAY_KEY_ID | Yes | Razorpay key |
RAZORPAY_KEY_SECRET | Yes | Razorpay secret |
SUPABASE_SERVICE_ROLE_KEY | Google OAuth | Supabase service role key |
PORT | β | Default: 3001 |
apps/web β Frontend
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_API_URL | Yes | Stoa API URL |
NEXT_PUBLIC_THIRDWEB_CLIENT_ID | Yes | thirdweb project client ID |
NEXT_PUBLIC_RAZORPAY_KEY_ID | Yes | Razorpay public key |
NEXT_PUBLIC_SUPABASE_URL | Yes | Supabase project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Yes | Supabase anon key |
apps/mcp-server β MCP Tools
| Variable | Required | Description |
|---|---|---|
STOA_API_URL | β | Default: production Railway URL |
STOA_API_KEY | Yes | User's API key for authenticated calls |
WALLET_PRIVATE_KEY | For x402 | Private key for on-chain payment signing |
Deployment
API Backend β Railway
The multi-stage Dockerfile builds shared β db β server:
FROM node:24-slim AS base
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml turbo.json tsconfig.base.json ./
COPY packages/shared/ packages/shared/
COPY packages/db/ packages/db/
COPY packages/server/ packages/server/
RUN pnpm install --frozen-lockfile && pnpm run build
EXPOSE 3001
CMD ["node", "packages/server/dist/index.js"]
Set all server env vars in Railway dashboard. Port: 3001.
Frontend β Vercel
cd apps/web && vercel deploy
Set NEXT_PUBLIC_* variables in Vercel project settings.
ML Models β HuggingFace Spaces
Each service in services/ is a standalone FastAPI app deployed as a Docker Space:
| Service | Space |
|---|---|
| Chest X-ray detection | hiteshx33-chest-xray-service |
| Plant disease detection | hiteshx33-plant-disease-service |
| Digital twin agent | HF Spaces (Docker SDK) |
Team
Built by Team Stoa for the Inceptrix Hackathon.
Base Sepolia Β· x402 Protocol Β· Coinbase CDP Β· HuggingFace Β· thirdweb
