
zhgg
On-chain AI agents that audit compliance on 0G and trade workflows over KeeperHub.
Demo
About
zhgg is an on-chain autonomous agent commerce platform where AI agents don't just run in the cloud — they live on a blockchain, own wallets, earn yield, sign contracts, and pay for compute with real USDC, all without human intervention. Each agent is an iNFT: an ERC-7857 token backed by a smart-contract receiver wallet (AgentReceiverWallet). The wallet parks idle balances into an ERC-4626 yield vault so capital is never sitting still. When an agent needs to act — audit another agent, hire a workflow, swap tokens, transfer funds — it does so through a full ERC stack: ERC-7710 for delegated spend-cap authorization so one agent can authorize another to spend on its behalf, and ERC-4337 UserOps routed through Pimlico's bundler for gasless account-abstraction execution. The operator console is a terminal UI. Agents live in terminals — text streams, log tails, wallet addresses. A TUI is the natural habitat. The operator types natural-language intents: `audit 2 mica`, `kh hire ml-risk-scorer`, `park 10 USDC`, `aa send 0xABCD... 0.01`. The dispatcher translates each into signed transactions, UserOps, or REST calls in real time, and an audit trail panel streams every on-chain event as it lands. The oracle agent runs TEE-backed inference on 0G Galileo, scoring agents against EU AI Act, MiCA, GDPR-AI, or price-oracle topics. Every score is committed on-chain via AxiomCommit (commitPlan → revealPlan) — a hash-locked audit trail that makes each agent's compliance history tamper-evident and publicly verifiable. The KeeperHub integration closes the agentic-commerce loop: agents can discover third-party ML workflows on the KeeperHub marketplace, inspect their inputSchema and price, and autonomously hire them via x402 micropayments — no human in the loop, no API key shared with the caller.
How it's made
**Runtime stack:** TypeScript throughout, running on Bun for sub-100ms cold starts and native ESM. The TUI uses raw ANSI escape codes and `process.stdout.write` — no ncurses, no blessed, no React. Each frame is built as a string diff and flushed atomically so there's never a partial-render flicker. A keypress handler translates operator input into typed `IntentCommand` unions that flow through a parser dispatcher to individual agent modules. **Chain integrations:** All on-chain writes use viem. 0G Galileo (chainId 16602) hosts the AgentNFT registry, AxiomCommit plan hashing, and AgentReceiverWallet yield vaults (ERC-4626). Base Sepolia hosts the DelegationManager for ERC-7710 spend-cap delegations. Pimlico's ERC-4337 v0.7 bundler handles UserOp submission and sponsorship for the AA wallet slice. **The hacky part — 0G receipt polling:** 0G Galileo's testnet nodes reject `eth_getTransactionReceipt` with an immediate error (not a null response) for any pending transaction. viem's `waitForTransactionReceipt` interprets that first-poll error as a hard failure and throws immediately, well before the configured timeout. The fix: fire-and-forget. We submit the transaction, snapshot the block number *before* submission (needed to deterministically derive the AxiomCommit `commitId` via `keccak256(tokenId ++ planHash ++ sender ++ blockNumber)`), return the derived ID to the caller immediately, and let `waitForTransactionReceipt` confirm in the background — errors silently swallowed as non-fatal. The on-chain record lands; the UX never blocks. **The hacky part — allowance:** ERC-20 `approve(amount)` on a re-used demo wallet gets consumed after the first run, causing `ERC20: transfer amount exceeds allowance` on every subsequent orchestration. Fix: check current allowance before every split; only re-approve if it's already below the payment amount, and approve `maxUint256` so the approval survives indefinitely across runs. **KeeperHub (partner tech):** The `kh discover` / `kh inspect` / `kh hire` intent chain lets the TUI browse KeeperHub's public MCP workflow marketplace (~85 entries), validate required inputSchema keys client-side, and pay-and-invoke via x402 in a single operator command. The bearer key lives only in the agent process; it's never surfaced in the TUI or commit history. **Oracle + TEE (0G):** The oracle agent sends a compliance-check prompt to a TEE-backed inference endpoint on 0G, receives a structured score, records the result on-chain via `giveFeedback` (ERC-8004 pattern), and commits the plan hash via AxiomCommit — all within a single `audit` intent. Topics (`eu-ai-act`, `mica`, `gdpr-ai`, `price`) are parsed at the TUI intent layer and passed through the full dispatch chain typed.