Skip to content

Repository files navigation

NEXUS

The verifiable AI-agent trust layer on 0G

Create an agent → own it as an ERC-7857 token whose encrypted brain lives on 0G Storage → run it in 0G Sealed Inference (TEE) → prove every run on-chain. Reputation comes from proofs, not reviews.

Zero Arena trades agents. CaaS clones them. NEXUS proves them.

▶ Live: https://nexus-alpha-five-26.vercel.app

Architecture · On-chain Proof · Setup · Docs

0G MAINNET · chainId 16661 · ERC-7857 + ERC-8004 · Sealed Inference TEE (TeeML, hardware-verified) · 51/51 contract tests · Galileo testnet fallback


What this is

When you "own" an AI-agent NFT today, you own a receipt — a pointer to metadata on someone else's server. The intelligence never moves, and when an agent does work for you there's no way to prove it used the model it claimed, stayed in budget, or followed its own rules. The agent economy is being built on "trust me."

NEXUS replaces "trust me" with "verify it":

  • Identity that IS the intelligence. ERC-7857 wraps the agent's encrypted persona on 0G Storage. Ownership transfers re-encrypt the brain for the buyer — the seller provably loses access.
  • Proof, not logs. Every task runs in 0G Sealed Inference (TEE) and returns a hardware-verified attestation. The proof is issued by the chip, not written by the operator.
  • Reputation that can't be gamed. Scores are computed from on-chain proofs and settled payments — every score change carries a receipt hash. No reviews.
  • A validator for the whole agent economy. NEXUS is a TEE validator for ERC-8004 (the Trustless-Agents standard with canonical registries live on 0G): any ERC-8004 agent, from any platform, can request a NEXUS validation and receive a hardware-backed Validation Response on-chain — proven live against an agent never minted in NEXUS.

Design Pattern

NEXUS establishes a verifiable trust lifecycle for AI agents through a strict cryptographic pipeline:

     Agent (ERC-7857) 
            │
            ▼
Encrypted Brain (0G Storage)
            │
            ▼
  Sealed Run (0G Compute TEE)
            │
            ▼
    Trace (0G Storage)
            │
            ▼
Composite Receipt (0G DA)
            │
            ▼
   Reputation (0G Chain)
  1. ERC-7857 Agent Identity: Every agent is an on-chain ERC-7857 iNFT. It controls its identity, creator royalties, and execution privileges. Vanilla transfers are disabled; ownership transfers can only occur via re-encryption, ensuring the seller provably loses access.
  2. Encrypted Persona on 0G Storage: The agent's "brain" (prompt, memory, policy) is encrypted using AES-256-GCM. The encryption key is wrapped to both the owner and the oracle using ECIES. Only the cipher reference (CID) is anchored on-chain.
  3. 0G Sealed Inference Run: Compute tasks run inside a 0G Compute TEE (Confidential Compute) using broker or router mode. The processor returns the model output along with a hardware-signed attestation.
  4. Proof/Trace Anchoring: The agent's runtime monitors and logs tool payloads, inputs, and outputs. This trace log is encrypted and uploaded to 0G Storage, producing an immutable trace CID.
  5. Composite Receipt: Once the session is closed and any native 0G escrow payments are settled, a CompositeReceipt is minted to 0G DA, binding the session, TEE signature, and escrow details.
  6. Proof-Based Reputation: The ReputationRegistry updates the agent's score and tier automatically on receipt minting. The score is computed strictly from on-chain receipt hashes—there are no fakeable user reviews.

Live 0G MAINNET Deployments (Wave 3)

All 5 contracts are deployed and source-verified on 0G Mainnet (Chain ID: 16661), with the full loop proven live — including a hardware-verified (TeeML) Sealed Inference run re-verifiable by anyone via processResponse:

ERC-8004 "Trustless Agents" layer (NEXUS is a TEE validator for the standard 0G ships natively):

Live mainnet proof index (auto-generated from chain, never hand-typed): docs/PROOFS.mainnet.md · append-only run artifacts: evidence/mainnet/

Proven live on 16661: mint (encrypted persona on mainnet 0G Storage) · re-encryption transfer with seller access-loss · clone + royalty · escrow with over-limit/wrong-merchant blocked on-chain · TTL refund · proof-only reputation (NotWriter guard) · TEE-verified inference receipt with AlreadyMinted replay guard · ERC-8004 validation loop (request → sealed run → on-chain TEE-backed response, including for an agent NEVER minted in NEXUS) · deterministic replay (same input → byte-identical output → fresh enclave proof) · offline proof bundles (verify a receipt air-gapped).

The app targets mainnet when NEXT_PUBLIC_USE_MAINNET=true (or OG_NETWORK=mainnet), with Galileo testnet as the always-on fallback — and one deployment serves both: the TESTNET / MAINNET switch in the header sends ?network= with every request, and the server runs that request on the chosen chain (withNetwork() in the SDK, AsyncLocalStorage — no process.env mutation, so concurrent requests never bleed). Selecting a network never selects a key: mainnet writes still require OG_MAINNET_KEY and testnet writes PRIVATE_KEY, so a browser can never talk a read-only deployment into signing. The switch shows LIVE or READ-ONLY for whichever network is active.


Live Galileo Testnet Deployments (Originality Proofs)

All contracts are compiled using Foundry and deployed directly to the 0G Galileo Testnet (Chain ID: 16602). These addresses are verifiable on the block explorer:


Status — Wave 3: full loop live on MAINNET

Wave 3 target Proven
5 contracts deployed + source-verified on 16661 docs/PROOFS.mainnet.md
Real mainnet mint / transfer / clone / escrow / refund / reputation evidence/mainnet/* (append-only, re-checkable via pnpm verify:proofs)
Hardware-verified Sealed Inference on mainnet (TeeML, processResponse === true) ✅ receipt #1, {provider, chatID} published for independent re-verification
ProofPass: /api/verify/[receiptId] + client-side RE-VERIFY LIVE + embeddable badge /proof/1 re-derives all 7 checks from chain + storage + enclave
Network switch with testnet fallback ✅ in-app TESTNET / MAINNET switch (per-request ?network=) + NEXT_PUBLIC_USE_MAINNET / OG_NETWORK
ERC-8004 portable identity (canonical registry, card on 0G Storage, hash on-chain) ✅ NEXUS agent #1 = ERC-8004 #3531152, evidence/mainnet/*erc8004-register
ERC-8004 TEE validation — incl. an EXTERNAL (non-NEXUS) agent evidence/mainnet/*erc8004-validate* (score 100/100, enclave re-verified)
Portable proof-anchored reputation in the canonical ERC-8004 Reputation Registry feedbackHash = NEXUS receiptHash; owner self-feedback blocked on-chain
Deterministic replay — re-run a receipt, byte-identical output, fresh TEE proof ✅ receipt #2 replayed (pnpm demo:replay 2); legacy receipts degrade gracefully
Offline proof bundles — verify air-gapped, tamper-evident pnpm verify:bundle evidence/bundles/receipt-mainnet-2.json
Trust leaderboard + public agent cards + QR /leaderboard, /agent/[id], /api/qr, agent badges
Full testnet parity for every mainnet capability ✅ Galileo: identity #380, validation 100/100, external agent #381, replay, bundle

Levels 0–3 (testnet baseline) ✅

Everything below ran against live 0G Galileo infrastructure (no mocks). Full tx links in docs/PROOF.md.

Level What Proven live
L0 4 gate-checks (mint · Sealed Inference TEE · 0G Storage · escrow)
L1 Create + own an agent, run a Sealed-Inference task ✅ 6 mints
L2 The prove loop: session → trace on 0G Storage → composite receipt → reputation ✅ 4 receipts
L3 Clone (royalty) · transfer (re-encryption) · escrow-paid task · proof page ✅ 3 clones, 1 transfer, 1 escrow settle

7 contracts deployed per network · forge test 51/51 · pnpm test:sdk 13/13 · tsc clean across app + SDK.


Quickstart

pnpm install
cp .env.example .env          # fill PRIVATE_KEY (funded 0G testnet wallet)
pnpm test:contracts           # 51/51
pnpm dev                      # → http://localhost:3000
  • / — the cinematic NEXUS world (districts)
  • /console — operator dashboard: create → run → prove, live profile cards
  • /proof/<receiptId>verify-in-30s proof page (5 on-chain facts)

Every one of those carries the TESTNET / MAINNET switch, and they share the choice (one NEXUS_NETWORK localStorage key): flip it in a district and /console, /leaderboard and /proof follow you onto the same chain.

Use it in your own project

The SDK is on npm — verify a real mainnet receipt from a clean project, no clone and no key required:

npm install 0g-nexus-sdk
process.env.OG_NETWORK = "mainnet";
const { verifyReceipt } = await import("0g-nexus-sdk");

const proof = await verifyReceipt("2");
console.log(proof.valid);   // true — every check recomputed live
for (const c of proof.checks) console.log(c.status ? "PASS" : "FAIL", c.claim);

Also exported: replayReceipt (deterministic re-run), exportProofBundle / verifyProofBundleOffline (air-gapped verification), and the full ERC-8004 adapter (registerIdentity, requestValidation, verifyValidation, giveFeedback). Package docs: https://www.npmjs.com/package/0g-nexus-sdk · Apache-2.0.

Reproduce the proofs straight from chain (no key needed):

pnpm gather:proofs -- --network mainnet   # regenerates docs/PROOFS.mainnet.md from live chain
OG_NETWORK=mainnet pnpm verify:proofs     # re-checks every evidence row (txs + storage roots)
pnpm test:sdk                             # crypto + re-encryption access-loss unit tests
./scripts/quickstart.sh                   # clean-clone reproducibility (A-07)

Run the live demos yourself (funded key required; add OG_NETWORK=mainnet for mainnet):

pnpm demo:mint      # encrypted persona on 0G Storage + ERC-7857 mint, fully asserted
pnpm demo:transfer  # THE MONEY-SHOT: re-encryption sale — seller provably loses access
pnpm demo:clone     # royalty clone
pnpm demo:escrow    # over-limit + wrong-merchant blocked on-chain, then lock→fulfill→settle
pnpm demo:refund    # TTL refund — funds can never lock
pnpm demo:rep       # proof-only reputation (direct write reverts NotWriter)
pnpm demo:receipt   # full prove-loop + TEE verify + AlreadyMinted replay guard

The ERC-8004 + replay layer (Wave 3+, live on mainnet):

pnpm demo:erc8004-register [id]   # portable identity in the CANONICAL ERC-8004 registry, card on 0G Storage
pnpm demo:validate                # validation loop: request → sealed TEE run → on-chain response → re-verify
pnpm demo:validate-external       # validate an agent NEVER minted in NEXUS (infrastructure, not walled garden)
pnpm demo:rep-feed                # NEXUS receiptHash-anchored feedback into the canonical Reputation Registry
pnpm demo:replay [receiptId]      # deterministic replay: same input → same output → fresh enclave proof
pnpm demo:bundle [receiptId]      # export + verify an offline proof bundle (tamper one byte → FAIL)
pnpm verify:bundle <file>         # air-gapped verification of any exported bundle

Architecture (one screen)

Browser (MetaMask) ─► Next.js app (one origin) ─► 0g-nexus-sdk ─► 0G Chain · 0G Storage · 0G Sealed Inference
   /d/*  districts        /api/* real backend       crypto·storage         5 contracts · encrypted brains · TEE
   /console dashboard      /proof/[id] proof page    inference·runtime

Two write paths: server-signed (operator key) and browser-wallet-signed (viem/MetaMask, so the user truly owns their agent). Full diagram + pipelines in docs/ARCHITECTURE.md.


The honest trust model (the pitch, and the viva armor)

Layer Strength
Inference Hardware-proven (Sealed Inference TEE signature)
Tool / trace log App-level, immutably anchored on 0G Storage + Chain (never claimed kernel-proven)
Transfer Trusted ECDSA signer (v1) → TEE/ZKP oracle (v2)

No overclaim: no on-chain TDX verification, no semantic fulfillment, testnet for compute.


Docs

All supplementary documentation, plans, specifications, and test configurations are organized inside the docs/ directory:


Stack

0G Chain (EVM, Foundry) · ERC-7857 · 0G Storage (@0gfoundation/0g-storage-ts-sdk) · 0G Sealed Inference (@0gfoundation/0g-compute-ts-sdk, broker mode) · native-0G escrow · Next.js 15 · React 19 · viem · Three.js districts.


Built for the 0G Bridge by AKINDO buildathon. · #BuildOn0G

About

NEXUS — the verifiable AI-agent trust layer on 0G. Own agents as ERC-7857 tokens, run them in Sealed Inference (TEE), prove every run on-chain. Levels 0–3 live on 0G Galileo testnet.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages