Six-Layer Platform Stack
Opacus is organized into six horizontal layers. Higher layers compose on top of lower ones; each layer has a clean interface to the one below it.
End-to-End Request Lifecycle
Every call from a user's browser to a blockchain transaction follows this path:
kineti_score_get from Agentboard
16 Products, One Kernel
Every product routes through the same api/agent-kernel.js entry point. The table below shows which Layer 2 module each product lives in and its current production status.
| Product | Primary Path(s) | Layer 2 Module | Chains | Status |
|---|---|---|---|---|
| Agent Kernel | /health / |
root handler, initStore, blobSaveStore | — | Live |
| OpacusPay | /v1/pay/balance /v1/pay/escrow/* |
collectFee, collectFeeOnChain, ledgerEntries | Base | Live |
| Kinetic Score (ERC-7755) | /runtime/task-execution → kineti_score_* |
calculateKineticScore, kineticScores store | 0G DA | Live |
| OpenClaw MCP | /openclaw/skills /openclaw/execute |
runtime/openclaw.ts, skill-loader.ts | — | Live |
| Base ↔ 0G Bridge | /v1/bridge/initiate /runtime/bridge-status |
bridge contract ABI, requestId event parsing | Base + 0G | Live |
| 0G Storage | /runtime/task-execution → og.storage.* |
@0gfoundation/0g-ts-sdk, ZgIndexer, ZgMemData | 0G | Live |
| 0G Compute / Inference | /runtime/task-execution → og.compute.* |
@0glabs/0g-serving-broker, ogComputeRequests | 0G | Live |
| Agent Citadel (DID) | /citadel/challenge /citadel/register |
ed25519 key derive, citadelAgents store | — | Live |
| ZK Proofs | /zk/prove /zk/verify |
snarkjs groth16, @noble/hashes, zkProofs store | 0G DA (anchor) | Live |
| TEE Enclave | /tee/attest /tee/verify |
DCAP simulation, ephemeral token, teeAttestations | 0G DA (anchor) | Live |
| Escrow | /escrows /escrows/lock /escrows/:id/release |
lockEscrowOnChain, EscrowV2 ABI | Base | Live |
| Gasless / Gas Station | /runtime/task-execution → gasless.* |
gasless/gas-station.service.ts, gasSponsorUsage | Base + 0G | Live |
| Intent Layer | /intent/submit /intent/status |
intent-builder, intent-broadcast, intent-redis | Cross-chain | Live |
| Execution Agents | /runtime/task-execution → agent:* |
trading-execution-agent, MEV / flash-loan bots | Base + 0G | Live |
| Space Agent (X Reward) | /runtime/task-execution → space.* |
space-agent/space-agent-service.ts | Base | Beta |
| Proofs Feed | /proofs/feed |
zkProofs + teeAttestations + escrows merge | — | Live |
On-Chain Contracts (Layer 1)
| Contract | Chain | Address | Purpose |
|---|---|---|---|
| Bridge Source | Base (8453) | 0x15c54901c4F313565c9B29C651fe20Ff6D59022e | initiateBridge() — locks USDC, emits BridgeInitiated event |
| Bridge Destination | 0G (16601) | 0x6A7F6d1F821Af4F7f8f2E01A3fb80e3f81BD27B5 | completeBridge() — mints USDC.e on receipt |
| Escrow V2 | 0G | 0x8E1c2aA49fe5a7611313bEf8188757AF35eF91C6 | lockFunds(), releaseFunds(), refundFunds() — trustless task budgets |
| USDC | Base | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | ERC-20 — primary payment token |
| USDC.e | 0G | 0x0d21B68b28234c07a46b7E3c2e7f0b7e1dBf9Ae3 | Bridged USDC on 0G — DEX liquidity |
| Jaine DEX Router | 0G | 0x8B598A7C136215A95ba0282b4d832B9f9801f2e2 | Uniswap V3 interface — exactInputSingle |
| Jaine Factory | 0G | 0x9bdcA5798E52e592A08e3b34d3F18EeF76Af7ef4 | Pool discovery — fee tiers 100 / 3000 / 10000 |
| Treasury | Base | 0xA943F46eE5f977067f07565CF1d31A10B68D7718 | Receives 1% platform fee (real USDC transfer) |
Transaction Flows
Expand any flow to see the exact step-by-step path through the system.
🌉 USDC Bridge: Base → 0G
🔐 ZK Proof → Kinetic Score Boost
🛡️ Escrow-Protected Task Execution
🤖 0G Compute Job (AI Inference)
🦀 OpenClaw MCP Skill (Cursor IDE integration)
🪪 Agent Citadel — DID Registration
State & Persistence Model
Opacus runs on Vercel serverless — there is no persistent process. All state is managed through a two-tier system:
globalThis store (in-memory)
Warm-instance cache. Shared across requests hitting the same Vercel instance. Lives for up to 4 seconds before a fresh blob load.
Vercel Blob KV (persistent)
JSON blob serialized to Vercel's edge blob storage. Every write calls blobSaveStore(). Reads refresh the in-memory cache.
0G DA Layer (immutable)
ZK proofs, TEE attestations, and Kinetic Score snapshots are anchored to 0G's Data Availability layer. Tamper-proof and verifiable forever.
On-chain (canonical)
Bridge requests, escrow locks, fee payments, and DEX swaps are permanently recorded on Base and 0G blockchains.
Store Schema (key fields)
Security Architecture
Rate Limiting
Auth endpoints: 10 req/15 min per IP. Billing: 10 req/5 min per user. General API: 60 req/min per user. Implemented in-process with sliding window counters.
HMAC Challenge Tokens
Stateless challenge-response for wallet login. HMAC-SHA256 signed with OPACUS_CHALLENGE_SECRET. Eliminates cross-instance state race conditions on Vercel.
JWT Auth
Bearer tokens for authenticated API calls. Session tokens stored in Vercel Blob KV, verified per request. Short-lived access tokens, rotating refresh tokens.
Ed25519 DID
Each agent's DID is derived deterministically from their wallet address using ed25519. No centralized registry — DIDs are self-sovereign and verifiable.
Input Validation
All external inputs validated at system boundaries. Address checksums verified via ethers.js. Amount ranges enforced. SQL injection impossible (no SQL layer).
CORS Guard
Origin restricted to https://opacus.xyz in production. Preflight OPTIONS handled. X-Content-Type-Options: nosniff on all responses.
Production Health
Real-time Service Status
Required Environment Variables
| Variable | Purpose | Required? |
|---|---|---|
BLOB_READ_WRITE_TOKEN | Vercel Blob KV — primary persistence store | Required |
OG_PRIVATE_KEY | Wallet for 0G DA uploads, bridge relaying, storage fees | Required |
OG_MAINNET_RPC_URL | 0G EVM RPC endpoint (default: evmrpc.0g.ai) | Optional |
OG_STORAGE_MAINNET_INDEXER | 0G Storage indexer URL | Optional |
ALCHEMY_BASE_RPC | Base mainnet RPC — bridge + USDC transfers | Required |
OPACUS_CHALLENGE_SECRET | HMAC secret for stateless challenge tokens | Required |
OPACUS_DEV_API_KEY | Dev bypass API key for testing | Dev only |
STRIPE_SECRET_KEY | Stripe billing integration | Optional |
TEE_SECRET | TEE ephemeral token signing secret (fallback for CHALLENGE_HMAC_SECRET) | Optional |
OPACUS_0G_STORAGE_SIMULATE | Set "true" to skip real 0G uploads in dev | Dev only |
Deployment Architecture
Vercel (Production)
Frontend (website/) served as static CDN. API (api/agent-kernel.js) as serverless function. Domain: opacus.xyz.
PM2 Bridge Relayer
Bridge relay process watches Base for BridgeInitiated events and calls completeBridge on 0G. Runs as separate Node.js process outside Vercel.
Local Dev
Run Agent Kernel locally with cd agent-kernel && npm run build && node dist/api-server.js on port 3006. Frontend via Python HTTP server on port 3000.