{
  "markdown": "# Coal\n\n> **0G APAC Hackathon 2026 — Track 3: Agentic Economy**\n>\n> Payments for humans **and** AI agents — one checkout, real USDC on Base, verifiable receipts on 0G.\n\n| Surface | URL |\n|---|---|\n| Marketing site | [usecoal.xyz](https://usecoal.xyz) |\n| Public API | [api.usecoal.xyz](https://api.usecoal.xyz) |\n| Hosted checkout | [usecoal.xyz/pay/...](https://usecoal.xyz) |\n| Live AI-agent demo (Claude buying ebooks) | [agent.usecoal.xyz](https://agent.usecoal.xyz) |\n| Demo merchant store (with download flow) | [store.usecoal.xyz](https://store.usecoal.xyz) |\n| MCP server (multi-tenant) | [mcp.usecoal.xyz/api/mcp](https://mcp.usecoal.xyz/api/mcp) |\n| x402 oracle paywall demo | [oracle.usecoal.xyz/api/price/ETH](https://oracle.usecoal.xyz/api/price/ETH) |\n| Live 0G health (all 5 components) | [api.usecoal.xyz/api/0g/health](https://api.usecoal.xyz/api/0g/health) |\n| Docs site | [usecoal.xyz/docs](https://usecoal.xyz/docs) |\n| React SDK on npm | [`coal-react`](https://www.npmjs.com/package/coal-react) v0.4.1 |\n\n## 🎥 Watch\n\n| Video | Length | Link |\n|---|---|---|\n| **Pitch video** (for judges) | ~5 min | **https://youtu.be/FOieBgJ3j4A** |\n| **Launch / demo video** (for users) | ~2 min | **https://youtu.be/fnlcOIcK-yk** |\n| **Pitch deck** (PDF) | 12 slides | **https://www.usecoal.xyz/coal-pitch-deck.pdf** |\n\n**Coal is a programmable commerce platform for hosted checkout, merchant APIs, payment links, paywalls, recurring billing, and agentic commerce flows.**\n\nCoal is built around a simple split:\n\n- `Coal` handles checkout orchestration, merchant operations, payer-info capture, recurring billing, and dual-protocol agent settlement flows on Base.\n- `0G` adds the sidecar layer for artifact storage, receipt proof anchoring, merchant memory, and AI commerce endpoints.\n\nThis repo is an active product branch, not a tiny demo. The current codebase includes:\n\n- hosted checkout and payment links (humans)\n- **dual-protocol agent payments** — Coinbase x402 (v1) and OKX APP (v2) on the same `/verify` endpoint\n- **MCP server** for Claude Desktop / Cursor / ChatGPT agents (multi-tenant, per-request credentials)\n- merchant dashboard and onboarding\n- payer-info collection at checkout\n- recurring billing foundations\n- widget/embed surfaces + `coal-react` SDK on npm\n- docs site + OpenAPI playground\n- demo store with verified-payment download flow\n- live agent demo running on 0G Compute (Qwen)\n- live 0G storage / chain / compute / KV / DA integration\n\n## 0G Integration — 5 Components on Mainnet\n\nCoal uses **five** 0G network components. **All live on 0G mainnet.** Full setup walkthrough lives on the docs site at [usecoal.xyz/docs](https://usecoal.xyz/docs).\n\n### 1. 0G Storage — Immutable Artifact Layer\nEvery payment receipt, merchant profile, and encrypted memory snapshot is published to 0G Storage as an immutable, content-addressed artifact. AI agents and apps can discover merchants and verify payments by reading these artifacts directly from the decentralized storage network.\n\n- **Receipt payloads:** tx hash, amount, payer address, merchant, metadata\n- **Merchant profiles:** name, products, paywalls, supported tokens, API endpoints\n- **Encrypted memory:** AES-256-GCM encrypted full catalog + settings (only Coal can decrypt)\n- Explorer: [storagescan.0g.ai](https://storagescan.0g.ai)\n\n### 2. 0G Chain — Receipt Proof Anchoring\nAfter publishing a receipt to 0G Storage, Coal anchors a SHA-256 hash of the receipt payload on-chain via the `CoalReceiptAnchor V2` smart contract. Creates a tamper-proof, independently verifiable proof that a specific payment happened at a specific time. V2 calls the DASigners precompile (`epochNumber()`) and embeds the current DA epoch into every anchor event.\n\n- Contract: `0x24a80A3Bb16d26D4063Ecd4B2fD64C6856E25E8b`\n- Chain: 0G mainnet (chain ID 16661)\n- Explorer: [chainscan.0g.ai/address/0x24a80A3B...](https://chainscan.0g.ai/address/0x24a80A3Bb16d26D4063Ecd4B2fD64C6856E25E8b)\n\n### 3. 0G Compute — AI Commerce Inference\nCoal's agent-facing APIs use 0G Compute for AI inference on the decentralized GPU network:\n\n- **Memory query:** Natural language Q&A against merchant data (\"What products does this merchant sell?\")\n- **Commerce routing:** AI decides which merchant or product fits an agent's request\n- **Policy evaluation:** AI evaluates scenarios against merchant rules (\"Can this customer get a refund?\")\n- **Sealed Inference:** Privacy-preserving inference with per-response TEE attestation via `broker.inference.verifyService()`. Responses from sealed queries carry a verification signature from the Intel TDX + NVIDIA H100/H200 enclave they ran inside.\n\n### 4. 0G KV — Mutable Merchant Mirror\nKV writes keep merchant profiles, memory pointers, and paywall manifests always-current on top of the 0G log layer, so agent discovery returns fresh data without walking the full log history.\n\n- `merchant:profile:latest` — merchant profile bundle\n- `merchant:memory:latest` — memory pointer (storage URI + root hash + timestamp)\n- `paywall:{id}:manifest:latest` — x402 paywall manifest\n\n### 5. 0G DA — Payment Event Streaming\nEvery confirmed payment, subscription lifecycle event, and webhook delivery is posted as a DA blob to the 0G Data Availability layer via a gRPC sidecar. External systems monitoring the DA stream see events in real time.\n\n- 6 event types: `payment_confirmed`, `subscription_created`, `subscription_renewed`, `webhook_delivered`, `paywall_access_granted`, `receipt_anchored`\n- In-memory demo feed: [api.usecoal.xyz/api/0g/da-events](https://api.usecoal.xyz/api/0g/da-events)\n\n### Architecture\n\n```mermaid\nflowchart TB\n    subgraph Actors\n        M[\"Merchant<br/><small>Console Dashboard</small>\"]\n        C[\"Customer<br/><small>Browser / Wallet</small>\"]\n        AG[\"AI Agent<br/><small>AgentKit / x402</small>\"]\n    end\n\n    subgraph Coal[\"Coal Platform\"]\n        direction TB\n        API[\"Console API<br/><small>Products, Links, Keys, Settings</small>\"]\n        CHK[\"Checkout Engine<br/><small>Sessions, Payments, Verification</small>\"]\n        PW[\"Paywall Gateway<br/><small>x402, Access Control, Manifests</small>\"]\n        RP[\"Receipt Publisher<br/><small>Proof Generation, Anchoring</small>\"]\n        ACI[\"Agent Commerce API<br/><small>Memory, Routing, Policy Eval</small>\"]\n        SUB[\"Subscription Engine<br/><small>Recurring Billing, Renewals</small>\"]\n        WH[\"Webhook Delivery<br/><small>Events, Retries, HMAC Signing</small>\"]\n        DB[(\"Neon Postgres\")]\n        AUTH[\"Privy Auth\"]\n    end\n\n    subgraph ZG[\"0G Network — 5 Components Live on Mainnet\"]\n        direction TB\n        ZGS[\"<b>1. 0G Storage</b><br/><small>Immutable receipt logs<br/>Merchant profiles<br/>Encrypted memory snapshots</small>\"]\n        ZGC[\"<b>2. 0G Chain</b><br/><small>CoalReceiptAnchor V2<br/>Calls DASigners precompile<br/>SHA-256 proof anchors</small>\"]\n        ZGX[\"<b>3. 0G Compute</b><br/><small>AI commerce inference<br/>Sealed Inference with TEE<br/>Per-response attestation</small>\"]\n        ZGK[\"<b>4. 0G KV</b><br/><small>Mutable merchant mirror<br/>Per-merchant stream IDs<br/>Live agent discovery</small>\"]\n        ZGD[\"<b>5. 0G DA</b><br/><small>Payment event streaming<br/>gRPC sidecar<br/>6 event types</small>\"]\n    end\n\n    BASE[\"<b>Base (Coinbase L2)</b><br/><small>USDC settlement<br/>RPC fallback: Alchemy → mainnet.base.org</small>\"]\n\n    M -->|API| API\n    C -->|Checkout| CHK\n    AG -->|x402 / API| PW\n    AG -->|Commerce| ACI\n\n    RP -->|publish| ZGS\n    RP -->|anchor| ZGC\n    ACI -->|infer| ZGX\n    API -->|mirror| ZGK\n    RP -->|DA events| ZGD\n\n    CHK --> BASE\n    API --> DB\n    API --> AUTH\n\n    style Coal fill:#1a1a2e,stroke:#334155,color:#e2e8f0\n    style ZG fill:#115e59,stroke:#2dd4bf,color:#ccfbf1\n    style BASE fill:#1d4ed8,stroke:#60a5fa,color:#bfdbfe\n    style Actors fill:#f8fafc,stroke:#cbd5e1,color:#1e293b\n```\n\n## Agent Payments — Dual-Protocol (x402 + OKX APP)\n\nCoal's paywall `/verify` endpoint accepts **both** payment envelopes on the same URL — Coinbase's x402 (v1) and OKX's APP (v2). The dispatch picks the right settlement path based on the header version:\n\n- **x402 v1** — Coinbase agent payment standard, EIP-3009 `transferWithAuthorization` on Base USDC. Gasless for the agent.\n- **APP v2** — OKX's agent payment whitepaper format. Same EIP-3009 wire underneath, different envelope.\n\nImplementation:\n\n- [`backend/lib/x402-settle.ts`](./backend/lib/x402-settle.ts) — x402 v1 settlement\n- [`backend/lib/app-settle.ts`](./backend/lib/app-settle.ts) — OKX APP v2 settlement\n- [`backend/app/api/paywalls/[id]/verify/route.ts`](./backend/app/api/paywalls/[id]/verify/route.ts) — version dispatch\n\nTry the live x402 paywall on the oracle demo:\n\n```bash\ncurl -i https://oracle.usecoal.xyz/api/price/ETH\n# returns 402 Payment Required with the X-PAYMENT challenge\n```\n\n## MCP Server (Claude Desktop / Cursor / ChatGPT)\n\nCoal ships a multi-tenant MCP server at [`mcp.usecoal.xyz/api/mcp`](https://mcp.usecoal.xyz/api/mcp). 13 tools cover the full agent-commerce loop:\n\n- `discover_merchants`, `search_products`, `get_merchant_profile`\n- `query_merchant_memory` (TEE-backed natural-language Q&A)\n- `check_paywall`, `create_checkout`, `get_checkout_status`\n- `verify_receipt` (3-step proof trail: Base TX → 0G Storage → 0G Chain)\n- `get_0g_health`, `agent_wallet_status`\n- `pay_merchant` (USDC on Base via EIP-3009, gasless)\n- `download_product` (verifies on-chain payment, returns signed download URL)\n- `setup_instructions`\n\nThe server holds **no long-lived secrets** — every user passes their own wallet key via `X-Coal-Agent-Key` and their own Coal API key via `X-Coal-Api-Key` on each request.\n\n```json\n// Claude Desktop config\n{\n  \"mcpServers\": {\n    \"coal\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"mcp-remote\",\n        \"https://mcp.usecoal.xyz/api/mcp\",\n        \"--header\",\n        \"X-Coal-Agent-Key:0xYOUR_WALLET_PRIVATE_KEY\"\n      ]\n    }\n  }\n}\n```\n\nSource: [`examples/coal-mcp-server/`](./examples/coal-mcp-server/). Docs: [`frontend/app/docs/sdk/mcp/`](./frontend/app/docs/sdk/mcp/).\n\n## What Is Live\n\n### Merchant product surface\n\n- Products, payment links, paywalls, API keys, team management, analytics, settings\n- Console auth through Privy\n- Async on-chain verification and webhook delivery\n- Hosted renewal checkouts for recurring billing\n\n### Checkout surface\n\n- Public checkout pages under `/pay/[slug]` and `/pay/checkout/[id]`\n- Payer-info configuration and validation\n- Direct settlement-token payments on Base\n- Widget/embed flow using the real checkout lifecycle\n\n### Agentic / 0G surface\n\n- Merchant profile publication to 0G Storage\n- Merchant memory snapshots with encrypted storage payloads\n- Verifiable receipt publication + 0G chain anchoring\n- Agent-facing paywall manifests and verification routes\n- AI commerce APIs backed by 0G Compute\n- Console operator page at `/console/0g`\n\n## 📈 Traction\n\n**Distribution:**\n- MCP server listed on [Smithery]([https://smithery.ai/server/coal-commerce) and the [official MCP Registry](https://registry.modelcontextprotocol.io/v0.1/servers?search=coal) as well as [PulseMCP](https://www.pulsemcp.com/servers/coal)\n- React SDK [`coal-react`](https://www.npmjs.com/package/coal-react) v0.4.1 shipped on npm\n- Documentation live at [usecoal.xyz/docs](https://usecoal.xyz/docs) with SDK, MCP, paywalls, agent-payments guides\n\n**Engagement beyond code:**\n- Walkthrough articles for builders + merchants\n- Small bounty program — developers building on top of Coal\n- Test users running live flows on the agent sandbox\n- Daily replies + DMs across X, LinkedIn, Farcaster, Reddit, Discord, Telegram\n\n**Inbound signal:**\n> *\"x402 + APP wire compat actually working is a real one… happy to point the mapper crawler at agent.usecoal.xyz for endpoint stability data in our public catalog.\"*\n> — CDP-verified Coinbase Developer Platform builder\n\n**Live proof anyone can check right now:**\n- API health: [api.usecoal.xyz/api/0g/health](https://api.usecoal.xyz/api/0g/health) → all 5 0G components green\n- Receipt anchor on 0G Chain: [`0x24a80A3Bb16d26D4063Ecd4B2fD64C6856E25E8b`](https://chainscan.0g.ai/address/0x24a80A3Bb16d26D4063Ecd4B2fD64C6856E25E8b)\n- Live agent demo: [agent.usecoal.xyz](https://agent.usecoal.xyz) → Claude buys products end-to-end on mainnet in under 10 seconds\n\n---\n\n## Project Stats\n\n| Metric | Value |\n|--------|-------|\n| Test suite | 500+ tests across 35 files |\n| 0G components live on mainnet | 5 — Storage, Chain, Compute, KV, DA |\n| 0G receipt anchor (mainnet) | [`0x24a80A3Bb16d26D4063Ecd4B2fD64C6856E25E8b`](https://chainscan.0g.ai/address/0x24a80A3Bb16d26D4063Ecd4B2fD64C6856E25E8b) |\n| Base USDC (mainnet) | [`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`](https://basescan.org/address/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) |\n| Networks | Base mainnet (USDC) + 0G mainnet (chain ID 16661) |\n| Agent-payment protocols supported | Coinbase x402 (v1) + OKX APP (v2) |\n| MCP tools | 13 |\n| React SDK | [`coal-react`](https://www.npmjs.com/package/coal-react) v0.4.1 |\n| Live demo (Claude buying ebooks) | [agent.usecoal.xyz](https://agent.usecoal.xyz) |\n| Live 0G health | [api.usecoal.xyz/api/0g/health](https://api.usecoal.xyz/api/0g/health) |\n\n## Quick Start for Judges\n\n1. **Watch an agent buy something autonomously:** open [agent.usecoal.xyz](https://agent.usecoal.xyz), fund a fresh agent wallet from the on-screen prompt, and ask Claude to buy any of the listed merchant products. End-to-end Base USDC payment + on-chain receipt + product download, no human in the loop.\n2. **Verify all 5 0G components live on mainnet:**\n   ```bash\n   curl -s https://api.usecoal.xyz/api/0g/health | python3 -m json.tool\n   ```\n   Expect `status: \"ok\"` with `storage`, `chain`, `compute`, `kv`, and `da` all `ok: true`.\n3. **Verify a receipt's 3-step proof trail:** visit `/verify/[session-id]` on any paid checkout — shows Base TX → 0G Storage root → 0G Chain anchor with explorer links to each.\n4. **Connect the MCP server to your own agent:** paste the config snippet from the [MCP Server](#mcp-server-claude-desktop--cursor--chatgpt) section above into Claude Desktop, restart, and the 13 Coal tools show up.\n5. **Try the dual-protocol paywall:** `curl -i https://oracle.usecoal.xyz/api/price/ETH` returns a 402 with the `X-PAYMENT` challenge, then resubmit with an x402 v1 OR an OKX APP v2 payment header and the same endpoint settles it.\n6. **Run an example locally:** clone the repo, `cd examples/coal-react-checkout`, `cp .env.example .env.local`, fill in your API key, `npm install && npm run dev`. See also `examples/demo-store/` for the merchant-side flow with verified downloads.\n7. **Browse the dashboard:** sign in at [usecoal.xyz](https://usecoal.xyz) with Privy → Console → 0G to see all 5 components with live mainnet status, activity feed, and publish controls.\n\n## Core Thesis\n\nCoal is not being replaced by 0G.\n\n- `Coal` is the payment execution and merchant operations layer.\n- `0G` is the storage, proof, memory, and AI layer around it.\n\nThat is the correct mental model for the repo.\n\n## Repo Layout\n\n```text\ncoal/\n├── backend/          # Next.js API app, Prisma, on-chain verification, 0G logic\n│   └── lib/0g/       # All 5 0G component implementations (Storage, Chain, Compute, KV, DA)\n├── frontend/         # Next.js UI app, docs site, dashboard, checkout surfaces\n├── contracts/        # CoalReceiptAnchor V2 Solidity contract + Foundry project\n├── coal-mini-app/    # World App mini-app frontend (separate deploy)\n├── packages/         # JS + React SDK surfaces\n├── examples/         # Runnable integrations:\n│   ├── coal-react-checkout/   # React checkout demo\n│   ├── coal-agent/            # Live AI-agent demo (Claude → Coal merchants)\n│   ├── coal-mcp-server/       # Multi-tenant MCP server\n│   ├── coal-oracle-agent/     # x402 oracle paywall demo\n│   ├── demo-store/            # Storefront with verified-payment download flow\n│   └── agentkit-action/       # AgentKit action provider\n├── scripts/          # Deploy + sync scripts\n└── README.md         # You are here\n```\n\n## System Architecture\n\nTwo separate Next.js apps are deployed from the same repo:\n\n- [backend](/Users/emmanuel/Documents/schemalabs/coal/backend) runs the API, verification jobs, agent routes, and 0G services\n- [frontend](/Users/emmanuel/Documents/schemalabs/coal/frontend) runs the dashboard, docs, checkout UI, and public pages\n\n## Examples\n\nThe repo also includes runnable integration examples under [examples](/Users/emmanuel/Documents/schemalabs/coal/examples):\n\n- [coal-react-checkout](/Users/emmanuel/Documents/schemalabs/coal/examples/coal-react-checkout)\n  A full Next.js checkout demo built on `@coal/react`, including hosted checkout launch, success handling, receipt verification, and an agent-style simulation flow.\n- [agentkit-action](/Users/emmanuel/Documents/schemalabs/coal/examples/agentkit-action)\n  A Coal action provider for AgentKit with checkout, receipt verification, paywall, merchant-memory, and policy-evaluation actions.\n- [demo-store](/Users/emmanuel/Documents/schemalabs/coal/examples/demo-store)\n  A storefront-style example that creates Coal sessions, receives webhooks, and now verifies receipts against the 0G proof trail.\n\nIf you want the quickest demo path, start with [coal-react-checkout](/Users/emmanuel/Documents/schemalabs/coal/examples/coal-react-checkout) and [examples/coal-react-checkout/README.md](/Users/emmanuel/Documents/schemalabs/coal/examples/coal-react-checkout/README.md).\n\n## Key Surfaces\n\n### Merchant-facing\n\n- [Console dashboard](/Users/emmanuel/Documents/schemalabs/coal/frontend/app/console/page.tsx)\n- [Products](/Users/emmanuel/Documents/schemalabs/coal/frontend/app/console/products/page.tsx)\n- [Payment links](/Users/emmanuel/Documents/schemalabs/coal/frontend/app/console/payment-links/page.tsx)\n- [Subscriptions](/Users/emmanuel/Documents/schemalabs/coal/frontend/app/console/subscriptions/page.tsx)\n- [0G operator page](/Users/emmanuel/Documents/schemalabs/coal/frontend/app/console/0g/page.tsx)\n\n### Public checkout\n\n- [Slug checkout](/Users/emmanuel/Documents/schemalabs/coal/frontend/app/pay/[slug]/page.tsx)\n- [Direct checkout session page](/Users/emmanuel/Documents/schemalabs/coal/frontend/app/pay/checkout/[id]/page.tsx)\n- [Payment view component](/Users/emmanuel/Documents/schemalabs/coal/frontend/components/PaymentView.tsx)\n\n### APIs\n\n- [Merchant API checkouts](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/checkouts/route.ts)\n- [Pay session](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/pay/session/route.ts)\n- [Pay confirm](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/pay/confirm/route.ts)\n- [Verify payments cron](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/cron/verify-payments/route.ts)\n- [0G health](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/0g/health/route.ts)\n- [Console 0G status](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/console/0g/route.ts)\n\n### Agent / 0G routes\n\n- [Merchant profiles](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/agent/merchant-profiles/[merchantId]/route.ts)\n- [Memory ingest](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/agent/memory/ingest/route.ts)\n- [Memory query](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/agent/memory/query/route.ts)\n- [Commerce route](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/agent/commerce/route/route.ts)\n- [Support answer](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/agent/commerce/support-answer/route.ts)\n- [Policy evaluation](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/agent/commerce/policy-eval/route.ts)\n- [Recommendations](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/agent/commerce/recommend/route.ts)\n\n## Authentication Model\n\nCoal has three auth surfaces:\n\n- **Merchant API requests** use `x-api-key` with `coal_live_*` keys\n- **Dashboard and `/api/console/*` routes** use Privy Bearer JWTs\n- **MCP server (per-request)** — each tool call carries the caller's own credentials in headers: `X-Coal-Agent-Key` (wallet private key, used by `pay_merchant` / `agent_wallet_status`) and `X-Coal-Api-Key` (Coal API key, used by `create_checkout` / `query_merchant_memory`). The server holds no long-lived secrets.\n\nLegacy Better Auth has been retired from runtime use.\n\n## Settlement Model\n\nCoal settles to the configured Base settlement token.\n\n- `USDC` is the fallback default\n- older `MNEE_*` environment aliases remain only as compatibility helpers\n- the product is no longer MNEE-first\n\n## Local Development\n\n### Prerequisites\n\n- Node.js `24+`\n- npm\n- Neon or another Postgres database\n- (Optional) Alchemy API key for Base — Coal falls back to a public Base RPC if you skip this, so you can run locally without one\n- Privy app credentials\n\n### 1. Install dependencies\n\n```bash\ncd backend && npm install\ncd ../frontend && npm install\ncd ..\n```\n\n### 2. Configure environment files\n\n```bash\ncp backend/.env.example backend/.env\ncp frontend/.env.example frontend/.env\n```\n\nThen fill in the required values in:\n\n- [backend/.env.example](/Users/emmanuel/Documents/schemalabs/coal/backend/.env.example)\n- [frontend/.env.example](/Users/emmanuel/Documents/schemalabs/coal/frontend/.env.example)\n\nImportant backend values:\n\n- `DATABASE_URL`\n- `ALCHEMY_API_KEY` *(optional — see RPC fallback note below)*\n- `BASE_RPC_FALLBACK_URL` *(optional — second-tier RPC, e.g. Coinbase Developer Platform or QuickNode)*\n- `PRIVY_APP_ID`\n- `PRIVY_APP_SECRET`\n- `NEXT_PUBLIC_FRONTEND_URL`\n- `NEXT_PUBLIC_API_URL`\n- `CRON_SECRET`\n\n**Base RPC fallback chain.** Coal wraps the Base RPC in a viem `fallback()` transport so a single provider outage cannot stop payments. Priority order: `ALCHEMY_API_KEY` (if set) → `BASE_RPC_FALLBACK_URL` (if set) → `https://mainnet.base.org` (always). The local public node is the floor so the app boots even without an Alchemy key. See [`backend/lib/chain.ts`](./backend/lib/chain.ts).\n\nImportant frontend values:\n\n- `NEXT_PUBLIC_API_URL`\n- `NEXT_PUBLIC_PRIVY_APP_ID`\n- `NEXT_PUBLIC_CHAIN_ENV`\n- `NEXT_PUBLIC_COINBASE_BUNDLER_KEY`\n\n### 3. Prepare the database\n\n```bash\ncd backend\nnpx prisma db push\n```\n\n### 4. Run both apps\n\nOpen two terminals:\n\n```bash\n# Terminal 1\ncd backend\nnpm run dev\n```\n\n```bash\n# Terminal 2\ncd frontend\nnpm run dev\n```\n\nDefault local URLs:\n\n- Frontend: `http://localhost:3000`\n- Backend: `http://localhost:3001`\n\n## Verification Commands\n\n### Backend\n\n```bash\ncd backend\nnpm run typecheck\nnpm test\nnpm run build\n```\n\n### Frontend\n\n```bash\ncd frontend\nnpm run typecheck\nnpm run build\n```\n\n### 0G storage benchmark\n\n```bash\ncd backend\nnpm run 0g:storage:benchmark\n```\n\n## 0G Notes\n\n0G is opt-in. Coal still works without it.\n\nFor complete setup instructions for all 5 components (Storage, Chain, Compute, KV, DA), see the docs site at [usecoal.xyz/docs](https://usecoal.xyz/docs).\n\nMinimum environment variables to enable 0G:\n\n```bash\n# Storage + Chain\nZERO_G_ENABLED=true\nZERO_G_CHAIN_RPC_URL=https://evmrpc.0g.ai\nZERO_G_CHAIN_PRIVATE_KEY=0x...\nZERO_G_RECEIPT_ANCHOR_ADDRESS=0x24a80A3Bb16d26D4063Ecd4B2fD64C6856E25E8b\nZERO_G_STORAGE_INDEXER_URL=https://indexer-storage-turbo.0g.ai\nZERO_G_STORAGE_ENCRYPTION_KEY=<32-byte hex>\n\n# Compute\nZERO_G_COMPUTE_ENABLED=true\nZERO_G_COMPUTE_PROVIDER=<provider_address>\nZERO_G_COMPUTE_BASE_URL=<provider_base_url>\nZERO_G_COMPUTE_API_KEY=<api_key>\nZERO_G_COMPUTE_MODEL=<model_name>\nZERO_G_SEALED_INFERENCE_ENABLED=true\n\n# KV\nZERO_G_STORAGE_STREAM_ID=0x<64-hex-chars>\n\n# DA (requires running a sidecar — see 0G-SETUP.md)\nZERO_G_DA_ENABLED=true\nZERO_G_DA_GRPC_URL=<sidecar_host>:51001\nZERO_G_DA_GRPC_TLS=false\n```\n\nThe main implementation lives in:\n\n- [`backend/lib/0g/storage.ts`](./backend/lib/0g/storage.ts) — Storage + KV\n- [`backend/lib/0g/chain.ts`](./backend/lib/0g/chain.ts) — Chain anchor writes\n- [`backend/lib/0g/compute.ts`](./backend/lib/0g/compute.ts) — AI inference + TEE attestation\n- [`backend/lib/0g/da.ts`](./backend/lib/0g/da.ts) — DA event streaming via gRPC\n- [`backend/lib/0g/merchant.ts`](./backend/lib/0g/merchant.ts) — merchant profile + memory publishing\n- [`backend/lib/receipts/proof.ts`](./backend/lib/receipts/proof.ts) — receipt proof pipeline\n- [`contracts/0g-receipt-anchor/src/CoalReceiptAnchor.sol`](./contracts/0g-receipt-anchor/src/CoalReceiptAnchor.sol) — V2 contract with DASigners precompile call\n\n## SDK / Widget\n\nCanonical package surfaces:\n\n- JS widget/runtime: [packages/coal-js/coal.js](/Users/emmanuel/Documents/schemalabs/coal/packages/coal-js/coal.js)\n- React package: [packages/react](/Users/emmanuel/Documents/schemalabs/coal/packages/react)\n- Public widget asset: [frontend/public/coal-widget.js](/Users/emmanuel/Documents/schemalabs/coal/frontend/public/coal-widget.js)\n\n## Docs\n\nCoal ships a docs site and a live docs playground:\n\n- Docs: `http://localhost:3000/docs`\n- Playground: `http://localhost:3001/api/docs/ui`\n\nKey files:\n\n- [frontend/app/docs](/Users/emmanuel/Documents/schemalabs/coal/frontend/app/docs)\n- [backend/app/api/docs/route.ts](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/docs/route.ts)\n- [backend/app/api/docs/ui/route.ts](/Users/emmanuel/Documents/schemalabs/coal/backend/app/api/docs/ui/route.ts)\n\n## Deployment\n\nCoal deploys as **six** Vercel projects from the same monorepo, each with its own `rootDirectory`:\n\n| Vercel project | Domain | Root |\n|---|---|---|\n| `coal` | [www.usecoal.xyz](https://www.usecoal.xyz) | `frontend/` |\n| `coal-backend` | [api.usecoal.xyz](https://api.usecoal.xyz) | `backend/` |\n| `coal-agent` | [agent.usecoal.xyz](https://agent.usecoal.xyz) | `examples/coal-agent/` |\n| `coal-mcp-server` | [mcp.usecoal.xyz](https://mcp.usecoal.xyz) | `examples/coal-mcp-server/` |\n| `coal-oracle-agent` | [oracle.usecoal.xyz](https://oracle.usecoal.xyz) | `examples/coal-oracle-agent/` |\n| `coal-demo-store` | [store.usecoal.xyz](https://store.usecoal.xyz) | `examples/demo-store/` |\n\nHelper scripts:\n\n- [`scripts/check-all.sh`](./scripts/check-all.sh) — backend + frontend typecheck + tests + build sweep.\n- [`scripts/deploy.sh`](./scripts/deploy.sh) — local prebuild + push to Vercel for any subset of the six projects.\n\n## Branch Strategy\n\n- `main` is the only branch on the public repo. Vercel production targets `main`.\n- All development happens through the public repo's `main` (PRs merge there).\n\n## 👥 Team\n\nThree co-founders, friends for years. Shipping consumer products, payments, and AI tools together.\n\n| Role | Name | LinkedIn |\n|---|---|---|\n| Co-founder · Engineering | **Emmanuel Haankwenda** | [linkedin.com/in/emmanuelhaankwenda](https://www.linkedin.com/in/emmanuelhaankwenda/) |\n| Co-founder · Engineering | **Bernard Namangala** | [linkedin.com/in/bernard-namangala](https://www.linkedin.com/in/bernard-namangala-665a231a5/) |\n| Co-founder · Product & Design | **Andre Haankwenda** | [linkedin.com/in/andrehaankwenda](https://www.linkedin.com/in/andrehaankwenda/) |\n\nCoal went from zero to mainnet in six weeks. None of that happens without this team.\n\n## License\n\n[MIT](./LICENSE) — Copyright (c) 2026 Coal.\n",
  "bytes": 27085,
  "sha": "bb2d1913214c061bb242939d3827a6fa372d9afc622272188dfb7e206814ed31",
  "repo_slug": "emmanuel39hanks/coal",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_emmanuel39hanks_coal_559d3e07/readme"
}