Note
Query402 participates in the Drips Network Stellar Wave program. This public repository is the canonical workspace for Wave issues and contributions.
Query402 is a hackathon-ready marketplace-style router where agents can buy search, news, and scrape results per request instead of paying monthly subscriptions.
- Agents should pay for exactly what they use.
- Providers can monetize API access per query.
- x402 + Stellar testnet enables programmable micropayment rails.
- Demo story is clear: compare providers → pay per request → get results → view spend analytics.
x402provides payment-required API patterns for paid HTTP routes.stellar:testnetprovides low-friction testing with programmable token payments.- Facilitator-based verification/settlement patterns are represented in the backend integration.
- TypeScript monorepo with npm workspaces.
- Express API with provider catalog and protected paid routes.
- Provider abstraction for
search,news,scrape. - Configurable per-request pricing.
- Usage + payment persistence in JSON (
apps/api/data/db.json). - Analytics endpoint for total spend and category breakdown.
- Agent CLI with commands for search/news/scrape.
- Deterministic
DEMO_MODEfallback for hackathon reliability. - Premium dark React dashboard with provider comparison, paid query workspace, results, and spend analytics.
Full technical breakdown: ARCHITECTURE.md
apps/api- Public routes:
/health,/api/providers,/api/catalog,/api/usage,/api/analytics - Protected routes:
/x402/search,/x402/news,/x402/scrape - Demo convenience route:
POST /api/demo/run - x402 integration in
src/lib/x402.ts(provider-aware dynamic route pricing) - Stellar config in
src/lib/stellar.ts - Pricing in
src/lib/pricing.ts - AI provider integration in
src/lib/groq.ts - Persistence in
src/lib/persistence.ts
- Public routes:
apps/agent-client- CLI commands for paid requests (
search,news,scrape) - Demo script (
npm run demo --workspace @query402/agent-client)
- CLI commands for paid requests (
apps/web- React + TypeScript + Vite + Tailwind frontend
- Query workspace, provider cards, demo toggle, result panel
- Usage and spend analytics dashboard
packages/shared- Shared Zod schemas and types used by API + client
.
├─ apps/
│ ├─ api/
│ ├─ agent-client/
│ └─ web/
├─ packages/
│ └─ shared/
├─ .env.example
├─ package.json
├─ tsconfig.base.json
├─ README.MD
└─ ARCHITECTURE.md
Copy .env.example to .env and fill values:
STELLAR_NETWORK(default:stellar:testnet)STELLAR_RPC_URLX402_FACILITATOR_URLX402_PAY_TO_ADDRESSDEMO_CLIENT_SECRET_KEYDEMO_CLIENT_PUBLIC_KEYPORT_APIAPI_BASE_URLVITE_API_BASE_URLCORS_ORIGINS(comma-separated allowed origins for API in production)DEMO_MODE(truefor deterministic demo reliability)- Optional keys:
BRAVE_API_KEY,SERPAPI_API_KEY,NEWS_API_KEY,GROQ_API_KEY,GROQ_MODEL
Deployment note:
- Render (API): set server vars like
GROQ_*,X402_*,CORS_ORIGINS. - Vercel (Web): set only
VITE_*vars (for exampleVITE_API_BASE_URL).
- Generate Stellar keypairs for payer and seller.
- Fund with Friendbot (testnet XLM).
- Add USDC testnet trustline for relevant accounts.
- Fund testnet USDC from Circle faucet.
npm install
npm run typecheck
npm run buildnpm run dev:apinpm run dev:webOpen: http://localhost:5173
Or production build:
npm run start:apiSearch:
npm run cli -- search "latest soroban updates" --provider search.basicNews:
npm run cli -- news "stablecoin micropayments" --provider news.fastScrape:
npm run cli -- scrape "https://developers.stellar.org" --provider scrape.pageFull CLI showcase:
npm run demo:agentReal payment validation (DEMO_MODE=false):
npm run validate:realIf this passes, output includes payment proof fields (payment-response, trace id, provider, price).
- Set
DEMO_MODE=falsein.env. - Fill real funded keys (not placeholders):
DEMO_CLIENT_SECRET_KEYDEMO_CLIENT_PUBLIC_KEYX402_PAY_TO_ADDRESSX402_FACILITATOR_API_KEY(forchannels.openzeppelin.comfacilitator)
- If needed, create facilitator key:
https://channels.openzeppelin.com/testnet/gen - Ensure API is running (
npm run dev:api). - Run
npm run validate:real. - Keep CLI output as judge proof screenshot/log.
Notes:
- Script checks API health and facilitator
/supportedreachability before payment attempt. - If facilitator/wallet funding is not ready, the script fails fast with explicit reason.
- Start API and Web.
- In the dashboard, show provider cards with price, quality, and latency fields.
- Select
search.basicand run the querylatest stellar x402 updates. - In the result panel, show provider, price, trace id, and timestamp fields.
- In the analytics panel, explain total spend and category breakdown.
- In the terminal, verify the same system through the CLI as a second channel.
Use these exact commands:
cd /Users/eminkaragoz/Desktop/projects/Query402
npm installTerminal 1:
cd /Users/eminkaragoz/Desktop/projects/Query402
npm run dev:apiTerminal 2:
cd /Users/eminkaragoz/Desktop/projects/Query402
npm run dev:webTerminal 3 (real payment proof):
cd /Users/eminkaragoz/Desktop/projects/Query402
npm run validate:real --workspace @query402/agent-clientOptional CLI proof:
cd /Users/eminkaragoz/Desktop/projects/Query402
npm run cli -- search "latest soroban updates" --provider search.basicExpected proof during demo:
Status: 200payment-responseheader value- provider and paid price in output
- usage/analytics counters increasing in dashboard
- Provider content generation:
search/news/scrape: AI-generated via Groq whenGROQ_API_KEYis configured.- Fallback: deterministic local provider outputs when Groq is unavailable or errors.
- Real x402 middleware integration: yes (
@x402/express,@x402/core,@x402/stellar). - Real Stellar payment execution: supported when
DEMO_MODE=falseand facilitator + funded wallets are reachable. - Hackathon reliability fallback:
DEMO_MODE=truereturns proper 402 semantics and deterministic paid retry behavior.
- Network config uses
stellar:testnet+ Soroban RPC URL. - Client and server include Stellar x402 scheme integration (
@x402/stellar). - Facilitator URL is fully environment-driven.
npm run validate:realprovides a reproducible real-payment validation path for demo day.
- Clear pay-per-request UX for agent internet access.
- End-to-end paid route flow with auditable usage and spend.
- Provider comparison model with price/latency/quality metadata.
- Practical monorepo architecture that can be extended quickly.
- Demo reliability without sacrificing real integration paths.
- No proprietary provider APIs required for baseline demo.
- Optional provider adapters can be added via env keys.
- Demo mode is explicitly documented for hackathon determinism.
- Add citation/link verification and stricter source quality filters for AI-generated results.
- Add richer payment metadata parsing from payment headers.
- Add SQLite persistence for more advanced analytics queries.
- Add integration tests with a reachable facilitator in CI.
Include these assets in your hackathon submission:
README.MDarchitecture.md- 3 screenshots:
- dashboard query workspace with provider cards
- successful paid result (trace + price visible)
- usage analytics panel (total + breakdown)
- short terminal capture of
npm run validate:real --workspace @query402/agent-client
Judge talking points (30-second version):
- Query402 lets agents buy internet access per request, not subscription.
- Paid routes are protected by x402 and settled on Stellar testnet.
- Marketplace UX compares providers by price, latency, and quality.
- Every paid call is logged into usage + spend analytics.
- Real payment flow is reproducible with one validator command.
- Monorepo setup
- Backend API with paid routes
- Agent CLI paid requests
- Usage + spend analytics
- Env + setup docs
- Frontend dashboard
