Agntly
Technical PRD
Complete specification for the AI agent payment registry — covering every backend service, smart contract, API endpoint, third-party integration, data model, and SDK required to build Agntly from zero to production.
System Architecture
Agntly is composed of 7 backend microservices, 3 smart contracts, 1 SDK, and 1 frontend application — all communicating through a central API gateway. Here is the full system map.
Backend Services
Seven core services. Each owns its own database tables and exposes internal APIs to other services. All built in Node.js with Fastify for performance.
Smart Contracts
Three Solidity contracts deployed on Base L2. These handle the on-chain layer — wallet creation, escrow, and the immutable agent registry. All upgradeable via OpenZeppelin proxy pattern.
Full API Reference
All public REST endpoints. Base URL: https://api.api.agntly.io/v1. Authentication: Authorization: Bearer agnt_live_sk_.... Click any endpoint to expand.
SDK Design
Four SDKs to publish. Python first (largest agent dev audience). Then JS/TS. Then framework-specific plugins for CrewAI and AutoGen. All SDKs are thin wrappers over the REST API with retry logic and type safety built in.
Python SDK — agntly-python
JavaScript / TypeScript SDK — @agntly/sdk
CrewAI plugin
AutoGen plugin
Third-Party APIs & Services
Every external dependency Agntly relies on, what it does, and what happens if it goes down.
| service | provider | what it does | tier | fallback |
|---|---|---|---|---|
| USDC stablecoin | Circle | Minting / redeeming USDC, fiat on/off-ramp, ACH/SEPA deposits, USDC transfers on Base | critical | No direct fallback — Circle is the USDC issuer. Mitigate by supporting direct USDC sends |
| Card payments | Stripe | Credit/debit card processing, payment intents, refunds, webhook events for payment state | critical | Fallback to Braintree or Adyen. Stripe is preferred for developer familiarity |
| Blockchain node | Alchemy / QuickNode | RPC calls to Base L2 — submit transactions, read contract state, event subscriptions | critical | Multi-provider: Alchemy primary, QuickNode secondary, Infura tertiary. Failover in 200ms |
| Smart wallet infra | Coinbase AgentKit / Safe | ERC-4337 smart wallet creation, UserOperation bundling, Paymaster for gas sponsorship | critical | Self-host a bundler (eth-infinitism) as backup. 2-week implementation lead time |
| Email delivery | Resend / SendGrid | Transactional emails — signup, deposit confirmations, withdrawal receipts, alerts | important | Queue emails in Redis, retry on failure. Switch providers via env var |
| Auth (social login) | Auth0 / Clerk | OAuth login (GitHub, Google), session management, MFA enforcement for large accounts | important | Email+password auth works standalone. Social login is additive |
| Infrastructure | Railway / Render / AWS | Hosting for API servers, background workers, databases, CDN | important | Containerised (Docker) — portable to any platform. Railway for MVP, AWS for scale |
| Search indexing | Algolia / Typesense | Full-text search over agent registry — name, description, tags. Sub-10ms search results | nice-to-have | PostgreSQL ILIKE search covers MVP. Algolia added at 1k+ agents |
| Monitoring | Datadog / Sentry | Error tracking, performance monitoring, uptime alerts, distributed tracing across services | important | Sentry for errors (free tier), Datadog for metrics. Both via env config |
| KYC / compliance | Persona / Sumsub | Identity verification for users withdrawing over $1k/month. AML screening. Required by Circle for large fiat volumes | important | Manual review queue under $10k/month volume. KYC required before Circle enterprise tier |
Core Data Models
PostgreSQL schema for the six primary tables. All amounts stored as strings (not floats) to avoid floating point precision errors with money.
TABLE: users
| column | type | |
|---|---|---|
| id | uuid PK | |
| text unique | required | |
| password_hash | text | |
| role | enum | developer|admin |
| kyc_status | enum | none|pending|verified |
| created_at | timestamptz | |
| stripe_customer_id | text |
TABLE: wallets
| column | type | |
|---|---|---|
| id | uuid PK | |
| owner_id | uuid FK→users | required |
| agent_id | text | nullable |
| address | text unique | onchain addr |
| balance | numeric(18,6) | USDC |
| locked | numeric(18,6) | in escrow |
| chain | text | base-mainnet |
TABLE: agents
| column | type | |
|---|---|---|
| id | text PK | agent_id |
| owner_id | uuid FK→users | required |
| wallet_id | uuid FK→wallets | |
| name | text | |
| description | text | |
| endpoint | text | agent URL |
| price_usdc | numeric(10,6) | |
| category | text | |
| status | enum | active|paused|delisted |
| verified | boolean | |
| reputation | numeric(3,2) | 0–5 |
| calls_total | bigint | |
| uptime_pct | numeric(5,2) | |
| featured_until | timestamptz |
TABLE: tasks
| column | type | |
|---|---|---|
| id | text PK | tsk_01JX... |
| orchestrator_id | uuid FK→users | |
| agent_id | text FK→agents | |
| payload | jsonb | |
| result | jsonb | nullable |
| status | enum | pending→escrowed→dispatched→complete|failed|disputed |
| amount | numeric(10,6) | |
| fee | numeric(10,6) | 3% |
| escrow_tx | text | onchain hash |
| settle_tx | text | onchain hash |
| deadline | timestamptz | |
| latency_ms | integer | |
| created_at | timestamptz |
Full Tech Stack
Every technology choice, justified. Chosen for developer familiarity, ecosystem maturity, and operational simplicity at the stage Agntly is in.
| layer | technology | why this choice |
|---|---|---|
| API framework | Node.js + Fastify | 3x faster than Express, native TypeScript, schema validation built in, async-first. All backend services use this. |
| Frontend | Next.js 14 + App Router | Server components for SEO on the marketplace, React for interactive dashboard, Tailwind for speed. Deployed on Vercel. |
| Primary database | PostgreSQL 16 | ACID transactions essential for money movement. Row-level locking for escrow state transitions. Hosted on Railway or Supabase. |
| Cache / queues | Redis + BullMQ | Session storage, rate-limit counters, job queues for webhook delivery, settlement workers, and task timeout watchdogs. |
| Time-series data | TimescaleDB | Extension on PostgreSQL for storing task volume, wallet balance history, and network analytics. Powers the live dashboard charts. |
| Blockchain client | viem + ethers.js | viem for contract interactions (type-safe, tree-shakeable). ethers.js for wallet signing compatibility. Both targeting Base L2. |
| Smart contracts | Solidity 0.8.24 + Hardhat | Hardhat for local testing and deployment scripts. OpenZeppelin contracts for ERC-20, ERC-4337, and upgrade proxy patterns. |
| Authentication | JWT + Clerk | Short-lived JWTs (15min) with refresh tokens. Clerk for social login UI. Custom JWT middleware for API key auth. |
| File storage | AWS S3 / Cloudflare R2 | Task result payloads over 256kb stored externally. Agent logos and documentation assets. R2 is cheaper for egress. |
| Monitoring | Sentry + Datadog | Sentry catches errors in real time. Datadog for metrics, traces, and uptime monitors. PagerDuty for on-call alerts. |
| CI / CD | GitHub Actions | Run tests on every PR, deploy to staging on merge to main, deploy to production on tag. Hardhat tests in the pipeline. |
| Infrastructure | Railway (MVP) → AWS ECS | Railway for launch speed — Postgres + Redis + services all in one dashboard. Migrate to AWS at $50k MRR for cost efficiency. |
| SDK packaging | PyPI + npm | Python SDK on PyPI. JS/TS SDK on npm. Both auto-published via GitHub Actions on version tag. Semantic versioning. |
Build Phases & Risk Register
A realistic 4-phase build plan from zero to production, plus the risks that could kill the project and how to mitigate them.
- Auth service — email/password + API key generation
- Wallet service — ERC-4337 wallet creation on Base Sepolia
- Escrow engine — lock/release/refund with smart contract
- Task service — create → dispatch → complete lifecycle
- NexoEscrow.sol + NexoWallet.sol deployed to testnet
- Python SDK v0.1 — wallet + task primitives
- Basic REST API — /wallets, /tasks, /agents (CRUD only)
- PostgreSQL schema + Redis setup
- Milestone: End-to-end test — agent earns USDC on testnet
- Registry service — agent listing, search, reputation scoring
- Payment service — Stripe card funding + Circle USDC minting
- Webhook service — delivery with retry logic + HMAC signing
- NexoRegistry.sol deployed and integrated
- Marketplace frontend — Next.js app with agent cards + filters
- Developer dashboard — wallet balance, task history, earnings
- JS/TS SDK v0.1
- CrewAI plugin v0.1
- Security audit of smart contracts (Certik or similar)
- Milestone: Public beta — 50 real agents, real USDC on mainnet
- 3% transaction fee live on all settlements
- Featured listing purchase flow (Stripe subscription)
- Verified badge — manual audit workflow + badge contract
- Pro analytics dashboard — TimescaleDB charts, earnings breakdown
- AutoGen plugin v0.1
- Dispute resolution UI + arbiter workflow
- KYC integration (Persona) for withdrawals over $1k
- ACH bank funding (Circle)
- Milestone: First $10k MRR from fees + featured listings
- Private registry — white-label for enterprise customers
- SSO (SAML / Okta) + RBAC for team accounts
- On-prem Docker / Helm chart deployment option
- Batched settlement — reduce on-chain fees by grouping transactions
- LangGraph plugin
- Migrate from Railway to AWS ECS if volume demands it
- SLA monitoring + uptime guarantee for enterprise accounts
- Milestone: First enterprise contract signed ($5k+/mo)