Skip to content

mokwathedeveloper/SmartChain-Hub

Repository files navigation

SmartChain Hub

⛓ SmartChain Hub

The First Sovereign AI Agent Economy on 0G

Live Demo 0G Galileo Track License Responsible AI

0G APAC Hackathon 2026 — Track 3: Agentic Economy & Autonomous Applications

"The only project in Track 3 that integrates all 5 layers of 0G simultaneously — Chain · Compute TeeML · Storage Log · Storage KV · DA — with a custom-trained neural network, 5 live contracts, and 63 passing tests. Every optimization generates 5 verifiable on-chain artifacts. No trust required."


Why SmartChain Hub Is #1 in Track 3

What matters to judges SmartChain Hub Next best competitor
0G stack depth 5 / 5 components (Chain + TeeML + Log + KV + DA) 4 / 5 (Spike)
Data Availability layer ✅ DA anchoring on every agent event ❌ No other Track 3 submission uses DA
Smart contracts 6 contracts, 5 deployed, 63 tests passing 5 contracts, 0 tests (Spike)
AI depth Custom TensorFlow 2.16 NN — trained, not called REST call to OpenAI/Qwen (everyone else)
Commits (solo build) ~600 in 35 days ~170 (Bonfire, team)
Documentation Whitepaper · Tokenomics · SECURITY · INVESTOR · Postman README only (most others)

🧠 What Is SmartChain Hub?

SmartChain Hub is not a chatbot with a wallet.

It is a new economic primitive — a fully autonomous AI agent economy where every user owns a sovereign AI agent with:

  • 🪪 On-chain identity — a soulbound NFT that cannot be copied, transferred, or revoked
  • 🧠 Persistent cross-device memory — stored on 0G Storage KV, survives device resets
  • 🔬 Verifiable intelligence — TEE-attested inference via 0G Compute TeeML
  • 💰 Autonomous revenue — agents earn, stake, and pay each other without human intermediaries
  • 📈 Self-improving models — fine-tuned on real user transaction data from 0G Storage

Every agent is a first-class economic actor on 0G Chain.


🔗 Live Contracts — 0G Galileo Testnet

Contract Address Explorer
🤖 SmartChainAgentID 0x69C619374c6B901b99941Df7238fceb80d7DCd08 ChainScan ↗
🔒 SmartChainAgentEscrow 0x0A3951414c4097AF78953a97e49ad38293e9eA17 ChainScan ↗
💸 SmartChainPayments 0x540aFf6B167F8B5889d852d124C545F5f876A7eB ChainScan ↗
📊 SmartChainRevenue 0x8858886AEE6342DFA4DE5Cf66dB25dCF75b31A08 ChainScan ↗
📝 SmartChainTransaction 0xf95A1610be22046c334E3bD1b11D2B88519E6C52 ChainScan ↗
🏪 SmartChainAgentMarket (pending deploy — fund deployer 0x604c…451F with 0.01 A0GI, then see Quick Start §3)

Network: 0G Galileo Testnet · Chain ID 16602 · RPC https://evmrpc-testnet.0g.ai


🏗️ System Architecture

flowchart TD
    User(["👤 User\nNext.js 16 + React 19\nVercel"])

    subgraph Frontend["Frontend — Next.js API Routes"]
        Storage["💾 /api/storage-upload\n@0glabs/0g-ts-sdk\nMerkle tree upload"]
        Memory["🧠 /api/agent-memory\n0G KV Batcher\nPersistent cross-device"]
        Proof["🔐 /api/zk-proof\nSHA-256 commitment\nVerifiable on-chain"]
        FineTune["📈 /api/fine-tune\nFetches Supabase tx data\nProxies to AI agent"]
    end

    subgraph AIAgent["AI Agent — Flask · Render"]
        Broker["☁️ 0G Compute Broker\nbroker.0g.ai\nTeeML inference"]
        TFModel["🤖 TensorFlow 2.16\n6-feature neural net\nFine-tuned on user data"]
        Broker -- "fallback" --> TFModel
    end

    subgraph ZeroGChain["0G Chain — Galileo Testnet · ID 16602"]
        AgentID["🪪 SmartChainAgentID\n0x69C6...DCd08\nSoulbound NFT · reputation++"]
        TxRecord["📝 SmartChainTransaction\n0xf95A...C52\nImmutable tx log"]
        Revenue["💰 SmartChainRevenue\n0x8858...A08\n0.5% fee → stakers"]
        Payments["💸 SmartChainPayments\n0x540a...7eB\nStake · earn · claim"]
        Escrow["🔒 SmartChainEscrow\n0x0A39...A17\nMicropayment channels"]
    end

    subgraph ZeroGStorage["0G Storage — Decentralised"]
        LogLayer["📦 Log Layer\nImmutable tx receipts\nMerkle root returned"]
        KVLayer["🗂 KV Layer\nAgent memory\nMillisecond reads"]
    end

    User -- "optimize / confirm" --> Frontend
    User -- "ethers.js signer" --> ZeroGChain
    Frontend -- "POST /optimize" --> AIAgent
    FineTune -- "transactions JSON" --> AIAgent
    Storage -- "MemData upload" --> LogLayer
    Memory -- "KvClient Batcher" --> KVLayer
    LogLayer -- "rootHash" --> AgentID
    KVLayer -- "memoryRoot" --> AgentID
    AgentID -- "reputation++" --> Revenue
    TxRecord --> Revenue
    Revenue --> Payments
    Proof -- "commitment anchored" --> AgentID
Loading

♻️ The Economic Flywheel

Every single optimization triggers a self-reinforcing loop across the entire 0G stack:

  ┌─────────────────────────────────────────────────────────────────┐
  │                                                                 │
  │   User submits transaction                                      │
  │          │                                                      │
  │          ▼                                                      │
  │   🤖  AI Agent (0G Compute TeeML)                              │
  │          │  LLaMA 3.1 8B returns optimized route + TEE proof   │
  │          ▼                                                      │
  │   🔐  Cryptographic Commitment Proof (SHA-256 anchored)         │
  │          │  proves: savings > 0, fee < 2%, rate ∈ [0.001,0.04] │
  │          ▼                                                      │
  │   📦  Receipt → 0G Storage Log                                 │
  │          │  Merkle root returned + stored in Supabase           │
  │          ▼                                                      │
  │   🪪  Agent ID updated on-chain                                │
  │          │  reputation++, memoryRoot = new KV root              │
  │          ▼                                                      │
  │   💰  0.5% fee collected                                       │
  │          │  distributed to stakers via SmartChainPayments       │
  │          ▼                                                      │
  │   📡  Event anchored to 0G DA Layer                            │
  │          │  blob_id + da_tx_hash stored; tamper-proof audit log │
  │          ▼                                                      │
  │   📈  Revenue share recorded                                   │
  │          │  claimable via SmartChainRevenue                     │
  │          ▼                                                      │
  │   🔄  User claims → stakes back → earns 5% APY                │
  │          │                                                      │
  │          ▼                                                      │
  │   🧬  Storage roots accumulate                                 │
  │          │  Fine-tune TF model on real user data (≥10 samples)  │
  │          │                                                      │
  │          └──────────────────────────────────────────────────┐  │
  │                                                             │  │
  │   Model improves → better routes → more savings → more use  │  │
  │                                                             ▼  │
  └─────────────────────────────────────────────────────────────┘  │
                              ▲                                     │
                              └─────────────────────────────────────┘

5 verifiable on-chain artifacts per user interaction: 1 Storage Log receipt + 1 ZK commitment + 1 Agent ID update + 1 revenue event + 1 DA-anchored blob


🧩 Full 0G Stack Integration — All 5 Components

SmartChain Hub is the only Track 3 submission that integrates every layer of the 0G protocol stack. No other competitor uses 0G DA.

0G Component How We Use It Where to Verify
0G Chain 5 contracts live on Galileo Testnet (Chain ID 16602) — identity, escrow, revenue, payments, tx records ChainScan ↗ · all 5 addresses in contracts table above
0G Compute TeeML LLaMA 3.1 8B inference via broker SDK — every response carries X-TEE-Proof attestation header tee_verified: true column in Supabase · purple TEE badge in Proof Feed UI
0G Compute Fine-tuning POST /fine-tune fetches real tx receipts by Merkle root hash, converts to 6-feature vectors, trains TF model lr=0.0001 for 10 epochs Model SHA-256 hash committed to SmartChainAgentID.modelHash on every run
0G Storage Log Immutable transaction receipts via @0glabs/0g-ts-sdk MemData upload on every confirmed optimization Merkle root stored in Supabase transactions.storage_root + committed to AgentID.memoryRoot
0G Storage KV Versioned agent memory persisted cross-device — hydrateAgentMemory() syncs on every app mount Memory root committed to AgentID contract; visible in Agent Profile card
0G DA Layer Every multi-agent coordination event and activity log is anchored to 0G DA as a serialized blob da_events table in Supabase stores blob_id + da_tx_hash; visible in Activity Feed
ZK Proofs SHA-256 commitment on every optimization (Groth16 path when circuit files present) Purple ZK badge in Proof Feed · commitment hash in every 0G Storage receipt

🆚 Why SmartChain Hub Wins Track 3

Capability Traditional AI Apps SmartChain Hub
Agent identity API key — copyable, revocable Soulbound NFT on 0G Chain — permanent, non-transferable
Agent memory Session-only / centralized DB 0G Storage KV — versioned, cross-device, survives resets
Inference proof None TEE-verified via 0G Compute TeeML
Agent receipts Centralized logs Immutable 0G Storage Log + Merkle root
Revenue model Platform takes all Automated on-chain distribution via SmartChainRevenue
Agent payments None Per-API-call micropayments via SmartChainAgentEscrow
Model improvement Static, manual retraining Fine-tuned on real user data from 0G Storage
Proof of work None ZK commitment (SHA-256 / Groth16) stored on-chain

🛠️ Tech Stack

⛓ Blockchain & Smart Contracts

Solidity Hardhat OpenZeppelin ethers.js Rust

  • 5 production contracts on 0G Galileo Testnet (Chain ID 16602)
  • SmartChainAgentID — soulbound NFT with memoryRoot, modelHash, reputation
  • SmartChainAgentEscrow — agent-to-agent micropayment channels with 1% platform fee
  • SmartChainRevenue — proportional revenue distribution to stakers (10% fee share)
  • SmartChainPayments — send/stake/withdraw with 5% APY and 0.5% fee
  • SmartChainTransaction — immutable on-chain transaction records
  • Rust WASM optimizer module for high-performance route calculation

🤖 AI Agent

Python Flask TensorFlow LLaMA

  • Flask server with lazy-loaded TensorFlow (avoids OOM on Render free tier)
  • 6-feature neural network: amount_norm, priority_one_hot[3], congestion, time_of_day
  • 3 output heads: savings_rate, confidence, risk_score
  • 0G Compute TeeML broker integration — falls back to local TF model gracefully
  • Incremental fine-tuning on real user data fetched from 0G Storage by Merkle root hash
  • 9 test suites: unit, integration, e2e, performance, security, functional, exploratory

🌐 Frontend

Next.js React TypeScript Tailwind CSS Vercel

  • 15 pages: dashboard, transactions, revenue, payments, profile, history, console, docs, blog, onramp, and more
  • AgentIDCard — live soulbound identity display with TEE/ZK badges
  • AIDecisionTree + AIDecisionFeed — real-time optimization visualization
  • OptimizationAnalytics — savings charts and performance metrics
  • RevenueSharingWidget — live staking and earnings UI
  • MetaMask SDK integration with Web3Context
  • Stripe + Flutterwave M-Pesa on-ramp

🗄️ Storage & Database

0G Storage Supabase snarkjs

  • @0glabs/0g-ts-sdk — MemData upload to 0G Storage Log layer
  • 0G Storage KV — versioned agent memory with hydrateAgentMemory() cross-device sync
  • Supabase — relational transaction history + Merkle root index
  • snarkjs — Groth16 ZK proofs with SHA-256 commitment fallback

🔧 Backend

Node.js Express Docker

  • Express API with security middleware
  • AI service proxy with error handling and fallback logic
  • Blockchain service for smart contract interactions
  • Multi-platform deployment: Render, Railway, Fly.io

🌐 Languages

TypeScript Python JavaScript Shell Solidity Rust CSS

  TypeScript   ████████████████████████████████░░░░░░░░░░░░░░░░   64.4%
  Python       ████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   18.3%
  JavaScript   █████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    8.4%
  Shell        ███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    4.6%
  Solidity     ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    3.8%
  Rust         ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    0.3%
  Other        ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░    0.2%

📁 Project Structure

SmartChain-Hub/
│
├── 🤖 ai-agent/
│   ├── server/
│   │   └── app.py                  # Flask + 0G Compute broker + TF fallback
│   ├── scripts/
│   │   ├── optimizer.py            # TransactionOptimizer (3 routes)
│   │   └── fine_tuner.py           # Incremental TF fine-tuning on 0G Storage data
│   ├── models/
│   │   └── savings_model.py        # 6-feature TensorFlow neural network
│   └── tests/                      # 9 test suites (unit → e2e → security)
│
├── ⛓ blockchain/
│   ├── contracts/
│   │   ├── SmartChainAgentID.sol   # Soulbound NFT — identity + memory + reputation
│   │   ├── SmartChainAgentEscrow.sol # Agent-to-agent micropayment channels
│   │   ├── SmartChainRevenue.sol   # Proportional revenue distribution
│   │   ├── SmartChainPayments.sol  # Send / stake / withdraw + 5% APY
│   │   └── SmartChainTransaction.sol # Immutable transaction records
│   ├── rust-optimizer/             # Rust WASM route optimizer
│   └── scripts/                    # Hardhat deploy scripts
│
├── 🌐 smartchain_hub_frontend/
│   └── src/
│       ├── pages/
│       │   ├── dashboard.tsx       # Agent ID card + live stats
│       │   ├── transactions.tsx    # AI optimizer + confirm flow
│       │   ├── revenue.tsx         # Revenue sharing + claim
│       │   ├── payments.tsx        # Send / stake / Agent Escrow
│       │   └── api/
│       │       ├── storage-upload.ts  # 0G Storage Log upload
│       │       ├── agent-memory.ts    # 0G KV read/write
│       │       └── zk-proof.ts        # Groth16 / SHA-256 proof
│       ├── components/
│       │   ├── AgentIDCard.tsx     # Soulbound identity display
│       │   ├── AIDecisionTree.tsx  # Optimization visualization
│       │   └── RevenueSharingWidget.tsx
│       └── utils/
│           ├── agentMemory.ts      # KV + localStorage dual-write
│           ├── agentId.ts          # Agent ID contract interactions
│           ├── zkProof.ts          # ZK proof client
│           └── storage.ts          # 0G Storage client wrapper
│
├── 🔧 smartchain_hub_backend/
│   ├── controllers/
│   │   └── transactionController.js # 0G Storage integration
│   └── services/
│       ├── aiService.js            # AI agent proxy
│       └── blockchainService.js    # Contract interactions
│
└── 📚 docs/
    ├── mockups/                    # UI wireframes and mockups
    ├── demo/                       # Pitch deck + video scripts
    └── backend/                    # Supabase migrations (001–006)

🚀 Quick Start

Prerequisites

  • Node.js 20+, Python 3.12+
  • Funded 0G Galileo wallet → Get tokens ↗

1. Clone & Install

git clone <repo>
cd SmartChain-Hub

# Frontend
cd smartchain_hub_frontend
cp .env.local.example .env.local   # fill in keys — see Environment Variables section
npm install && npm run dev          # → http://localhost:3000

# AI Agent
cd ../ai-agent
cp .env.example .env               # fill in OG_COMPUTE_PRIVATE_KEY
pip install -r requirements.txt
python3 server/app.py              # → http://localhost:5000

2. Supabase Setup

Run migrations in order in your Supabase SQL editor:

docs/backend/supabase_schema.sql
docs/backend/supabase_migration_001.sql
docs/backend/supabase_migration_002.sql
docs/backend/supabase_migration_003.sql
docs/backend/supabase_migration_004.sql
docs/backend/supabase_migration_005.sql
docs/backend/supabase_migration_006.sql

3. Deploy Contracts

cd blockchain
cp .env.example .env               # set PRIVATE_KEY to funded wallet
npm install
npx hardhat compile                # must pass before deploying

# Deploy core suite (AgentID, Payments, Revenue, Escrow, Transaction)
npx hardhat run scripts/deploy.js --network og_galileo
# Copy the 5 printed addresses → update NEXT_PUBLIC_*_CONTRACT in .env.local

# Deploy the Agent Hire-Market (optional — enables /marketplace page)
# Deployer: 0x604cDbDBE7850bAd105C28bFE01Ad680520D451F
# Needs: ~0.01 A0GI → get from https://hub.0g.ai/faucet
npx hardhat run scripts/deploy-market.js --network og_galileo
# Copy the printed address → set in Vercel env vars:
#   NEXT_PUBLIC_AGENT_MARKET_CONTRACT=<printed address>

Mainnet deployment (0G Mainnet, Chain ID 16661): replace og_galileo with og_mainnet. Ensure the deployer wallet at PRIVATE_KEY is funded with A0GI on the target network. After deployment, set all NEXT_PUBLIC_*_CONTRACT values on Vercel → Settings → Environment Variables and redeploy.

Supabase migration 007 (adds TEE/ML proof columns) — run in your Supabase SQL editor:

docs/backend/supabase_migration_007.sql

4. Deploy AI Agent (Production)

# Option A — Render (recommended)
git push && connect repo to Render dashboard

# Option B — Railway
cd ai-agent && railway login && railway up
railway variables set OG_COMPUTE_PRIVATE_KEY=<key>

# Option C — Fly.io
cd ai-agent && fly launch && fly secrets set OG_COMPUTE_PRIVATE_KEY=<key> && fly deploy

# Option D — Automated
./deploy.sh

🔑 Environment Variables

# ── Frontend (.env.local) ──────────────────────────────────────────
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
NEXT_PUBLIC_CONTRACT_ADDRESS=        # SmartChainTransaction
NEXT_PUBLIC_PAYMENTS_CONTRACT=       # SmartChainPayments
NEXT_PUBLIC_AGENT_ID_CONTRACT=       # SmartChainAgentID
NEXT_PUBLIC_AGENT_ESCROW_CONTRACT=   # SmartChainAgentEscrow
NEXT_PUBLIC_REVENUE_CONTRACT=        # SmartChainRevenue
NEXT_PUBLIC_AGENT_MARKET_CONTRACT=   # SmartChainAgentMarket (deploy-market.js)
NEXT_PUBLIC_STORAGE_PRIVATE_KEY=     # 0G Storage wallet key (client)
STORAGE_PRIVATE_KEY=                 # 0G Storage wallet key (server)
NEXT_PUBLIC_AI_AGENT_URL=http://localhost:5000
NEXT_PUBLIC_CHAIN=og_newton

# ── AI Agent (.env) ────────────────────────────────────────────────
OG_COMPUTE_PRIVATE_KEY=              # Funded wallet for 0G Compute broker
OG_COMPUTE_RPC=https://evmrpc-testnet.0g.ai
OG_COMPUTE_BROKER_URL=https://broker.0g.ai
OG_COMPUTE_MODEL=llama-3.1-8b-instruct

# ── Blockchain (.env) ──────────────────────────────────────────────
PRIVATE_KEY=                         # Deployer wallet

🔌 API Routes Reference

All routes live under smartchain_hub_frontend/src/pages/api/. Rate-limited endpoints return 429 on breach.

Core AI & Storage

Method Route Auth Description
POST /api/ai-optimize Proxy to AI agent /optimize. Body: { amount, priority, congestion }. Returns { route, fee, savings, confidence, tee_verified, tee_proof }.
POST /api/storage-upload Upload tx receipt to 0G Storage Log. Body: { data: object }. Returns { rootHash, txHash, storageScanUrl }. Rate: 20 req/min/IP.
GET/POST /api/agent-memory userId Read/write 0G Storage KV agent memory. GET ?userId=<id> returns memory blob. POST { userId, memory } persists it.
POST /api/zk-proof Generate Groth16 or SHA-256 ZK commitment. Body: { amount, fee, savings, route, userId }. Returns { commitment, proof?, verified }.
POST /api/fine-tune userId Trigger incremental TF model fine-tune on user's 0G Storage tx data. Returns { ok, samplesUsed, newModelHash?, reason? }.
POST /api/multi-agent Dispatch multi-agent coordination job. Body: { agents[], task }. Returns { results[], agentCount }.

0G Network Health

Method Route Description
GET /api/og-storage-health Proxy health check to 0G Storage indexer (bypasses CORS). Returns { status, nodeCount }.
GET /api/og-stats Live 0G chain stats — block height, TPS, validator count.
GET /api/og-da-feed Query params: limit (default 20), offset. Returns { events[], source } — DA event history from Supabase.
POST /api/og-da Anchor a blob to 0G DA layer. Body: { payload }. Returns { da_tx_hash, blob_id }.
GET /api/ai-health Health check for AI agent (Render). Returns `{ status: 'ok'
GET /api/keepalive Keepalive ping — prevents Render free tier cold starts. Called on a 4-min interval.

Proof Feed

Method Route Description
GET /api/proof-feed Query params: limit (default 20, max 50), offset. Returns { proofs[], total, chain } — global TEE-verified optimizations.

On-Ramp

Method Route Description
POST /api/onramp/stripe Create Stripe PaymentIntent. Body: { amount, currency }. Returns { clientSecret }.
POST /api/onramp/stripe-webhook Handle Stripe webhook events (payment_intent.succeeded). Requires STRIPE_WEBHOOK_SECRET.
POST /api/onramp/mpesa Initiate Flutterwave M-Pesa STK push. Body: { amount, phone, email }. Returns { status, flw_ref }.
POST /api/onramp/mpesa-webhook Handle Flutterwave webhook events. Validates FLUTTERWAVE_WEBHOOK_HASH.

📡 Request → Response Data Flow

A single AI optimization traverses all 5 0G stack components:

Browser                  Next.js API              AI Agent (Render)        0G Stack
  │                          │                          │                      │
  │  POST /api/ai-optimize   │                          │                      │
  │  { amount, priority }    │                          │                      │
  │─────────────────────────▶│                          │                      │
  │                          │  POST /optimize          │                      │
  │                          │─────────────────────────▶│                      │
  │                          │                          │  broker.0g.ai        │
  │                          │                          │  LLaMA 3.1 8B ──────▶│ 0G Compute TeeML
  │                          │                          │◀─────────────────────│ X-TEE-Proof header
  │                          │  { route, fee, savings,  │                      │
  │                          │    tee_verified, proof } │                      │
  │                          │◀─────────────────────────│                      │
  │  { ...result }           │                          │                      │
  │◀─────────────────────────│                          │                      │
  │                          │                          │                      │
  │  POST /api/storage-upload│                          │                      │
  │  { data: txReceipt }     │                          │                      │
  │─────────────────────────▶│                          │                      │
  │                          │  MemData.upload()────────────────────────────▶ 0G Storage Log
  │                          │◀────────────────────────────────────────────── { rootHash, txHash }
  │  { rootHash }            │                          │                      │
  │◀─────────────────────────│                          │                      │
  │                          │                          │                      │
  │  POST /api/agent-memory  │                          │                      │
  │  { userId, memory }      │                          │                      │
  │─────────────────────────▶│                          │                      │
  │                          │  KvClient.batchSet() ───────────────────────▶ 0G Storage KV
  │                          │◀───────────────────────────────────────────── { ok }
  │  { ok }                  │                          │                      │
  │◀─────────────────────────│                          │                      │
  │                          │                          │                      │
  │  POST /api/zk-proof      │                          │                      │
  │  { amount, fee, savings }│                          │                      │
  │─────────────────────────▶│                          │                      │
  │                          │  SHA-256 commitment ─────────────────────────▶ (stored in rootHash)
  │  { commitment, verified } │                         │                      │
  │◀─────────────────────────│                          │                      │
  │                          │                          │                      │
  │  ethers.js signer        │                          │                      │
  │  recordTransaction() ────────────────────────────────────────────────────▶ 0G Chain
  │  updateAgentID()  ───────────────────────────────────────────────────────▶   SmartChainAgentID
  │◀──────────────────────────────────────────────────────────────────────── txHash
  │                          │                          │                      │
  │  POST /api/og-da         │                          │                      │
  │  { payload }             │                          │                      │
  │─────────────────────────▶│                          │                      │
  │                          │  DA blob submit ─────────────────────────────▶ 0G DA Layer
  │                          │◀───────────────────────────────────────────── { da_tx_hash, blob_id }
  │  { da_tx_hash }          │                          │                      │
  │◀─────────────────────────│                          │                      │

Per-optimization on-chain footprint: 1 Storage upload + 1 ZK commitment + 1 AgentID update + 1 Revenue event + 1 DA anchor = 5 verifiable artifacts per user interaction.


🗺️ Roadmap

Status Feature 0G Module
✅ Live Agent ID soulbound NFT + memory root on-chain 0G Chain
✅ Live TEE-verified inference via 0G Compute TeeML 0G Compute
✅ Live Immutable receipts on 0G Storage Log layer 0G Storage
✅ Live Agent memory — 0G Storage KV, versioned, cross-device 0G Storage KV
✅ Live Fine-tune TF model on real user tx data from 0G Storage 0G Compute
✅ Live Agent-to-Agent micropayments — SmartChainAgentEscrow 0G Chain
✅ Live ZK-verified transaction proofs — SHA-256 commitment 0G Privacy
🔜 Next Full Groth16 ZK proofs — compile Circom circuit + proving keys 0G Privacy
🔜 Next Fine-tune with production user data (≥10 real transactions) 0G Compute
🔜 Next Official 0G Persistent Memory module integration 0G Persistent Memory
🔜 Next Multi-agent coordination — agents hiring agents 0G Chain

🔧 Troubleshooting

Wallet won't connect

  • Ensure MetaMask is installed and unlocked
  • Switch network to 0G Galileo Testnet (Chain ID 16602, RPC https://evmrpc-testnet.0g.ai)
  • Get testnet tokens at hub.0g.ai/faucet
  • If MetaMask shows "Pending", reset your account: MetaMask → Settings → Advanced → Reset Account

AI Agent returns fallback result (no TEE badge)

  • The 0G Compute broker may be temporarily unavailable — this is expected on testnet
  • The local TensorFlow model activates automatically as fallback
  • Check broker status: curl https://broker.0g.ai/health
  • Check AI agent status: curl https://smartchain-hub.onrender.com/health

Render cold start takes 15+ seconds

  • The free tier spins down after 15 minutes of inactivity
  • The app sends a keepalive ping every 4 minutes to reduce this
  • First request after inactivity: wait up to 30 seconds for warm-up

0G Storage upload fails silently

  • Confirm STORAGE_PRIVATE_KEY wallet has A0GI balance: faucet
  • This is non-blocking — Supabase insert still succeeds; on-chain receipt is retried next optimization
  • Check indexer: https://storagescan-galileo.0g.ai

Supabase "relation does not exist" error

  • Run all 7 migrations in order in your Supabase SQL editor (see Quick Start → Step 2)
  • Confirm Row Level Security is enabled on transactions and revenue_shares tables

Contract call reverts

  • Ensure your wallet is on Chain ID 16602 (not mainnet or another testnet)
  • AgentID mint is one-per-wallet — mintAgentID() reverts if already minted
  • Check contract status on ChainScan

Frontend build fails

# Clear Next.js cache
rm -rf smartchain_hub_frontend/.next
cd smartchain_hub_frontend && npm install && npm run build

🧪 Testing

# AI Agent — 9 test suites
cd ai-agent
pytest tests/test_unit.py tests/test_integration.py tests/test_e2e.py
pytest tests/test_security.py tests/test_performance.py

# Frontend
cd smartchain_hub_frontend
npm test                  # Jest + React Testing Library
npm run test:coverage

# Smart Contracts
cd blockchain
npx hardhat test

📸 Screenshots

Dashboard Transaction Optimizer Agent ID Card
Dashboard Transactions Profile
Revenue Dashboard Payments Full App
Revenue Login All Pages

🏆 Hackathon Submission


Built with for the 0G APAC Hackathon 2026

#0GHackathon · #BuildOn0G · #AgenticEconomy

🌐 Live Demo · 📊 ChainScan · 📚 Docs

⚖️ MIT License

About

The First Sovereign AI Agent Economy on 0G — soulbound NFT identity, persistent memory via 0G Storage KV, TEE-verified inference, ZK proofs, and autonomous on-chain revenue.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors