Skip to content

tupils1/chainsight

Repository files navigation

ChainSight

Natural-language on-chain analyst with verifiable AI answers — the ETHOnline 2026 build.

Ask a plain-English question about any wallet, token, or protocol. A tool-calling agent decomposes it into live queries across The Graph, Hedera, and Blockscout, synthesizes a sourced, charted answer, runs the reasoning on (optionally) the 0G Compute network, and notarizes the question + exact queries + raw rows + output to 0G Storage. A "View provenance" panel replays exactly what ran, with a tamper-evident receipt hash.

Bounty strategy (verified against the live ETHOnline 2026 prizes page, $60k total)

Sponsor Pool ChainSight fit
The Graph $15k 🟢 primary — Token API + subgraph gateway, agent routes among data sources
0G $15k 🟢 strong — 0G Storage provenance (live) + 0G Compute (env-swap) = "verifiable AI"
Hedera $15k 🟢 added — Mirror Node tool (accounts, HTS tokens, holdings), keyless
1inch $10k ❌ swap/aggregation, not a read-only analyst
Uniswap Foundation $5k ⚪ weak — rewards building on Uniswap, not reading it

Blockscout is NOT an ETHOnline 2026 sponsor. Its MCP integration is kept as a real demo enhancement (ENS resolution, address/NFT intelligence, contract source) — not a prize pillar.

Stack

  • Next.js 14 (App Router) + TypeScript
  • openai SDK against an OpenAI-compatible base URL (dev: DeepSeek; submission: 0G Compute Router — env-swap)
  • Agent tools: The Graph Token API + subgraph gateway, Hedera Mirror Node, Blockscout (REST + MCP), render_chart
  • Provenance: content-addressed receipts → local (fast dev) or 0g (on-chain 0G Storage)
  • Recharts for auto-generated charts

Quick start

npm install
cp .env.example .env.local   # fill keys (see below)
npm run smoke -- "your question"   # CLI: run the agent on one question
npm run dev                        # http://localhost:3000
npm run typecheck                  # tsc --noEmit

Credentials

In .env.local (gitignored). Hedera + Blockscout need no key.

Var For Status
LLM_API_KEY DeepSeek (dev LLM) — platform.deepseek.com needed
GRAPH_TOKEN_API_KEY The Graph Token API JWT — thegraph.market (generate an Access Token, not the raw key) needed
GRAPH_GATEWAY_API_KEY Subgraph queries — thegraph.com/studio API key needed
ZG_PRIVATE_KEY 0G Storage — funded Galileo testnet wallet (faucet.0g.ai); set PROVENANCE_BACKEND=0g for on-chain demo
(submission) 0G Compute — sk- key from pc.0g.ai → swap the 3 LLM_* vars to router-api.0g.ai/v1 deferred

Verified integration specs (live as of 2026-06)

  • The Graph Token API — base https://token-api.thegraph.com/v1; paths /evm/{balances,transfers,holders,tokens}, network+address/contract as query params; Bearer <JWT> (Access Token from thegraph.market). lib/tools/graphToken.ts
  • The Graph subgraphs — gateway https://gateway.thegraph.com/api/<key>/subgraphs/id/<id>; Uniswap V3 mainnet 5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV (order by volumeUSD — TVL is spam-inflated). lib/tools/subgraph.ts
  • Hedera Mirror Nodehttps://mainnet-public.mirrornode.hedera.com/api/v1 (keyless); /accounts/{id|0xevm}, /tokens/{id}, /accounts/{id}/tokens. HBAR balances are tinybars (÷1e8). lib/tools/hedera.ts
  • 0G Storage@0gfoundation/0g-storage-ts-sdk@1.2.10, in-memory MemData upload, Galileo testnet; proven live (real rootHash 0g://0x75e4…). lib/provenance0g.ts (PROVENANCE_BACKEND=0g)
  • 0G Compute — OpenAI-compatible router https://router-api.0g.ai/v1, sk- key, models deepseek-v3/0gm-1.0-35b-a3b. No code change — lib/llm.ts is env-driven. (testnet router has no tool-calling model.)
  • Blockscout MCP (non-sponsor enhancement) — https://mcp.blockscout.com/mcp (Streamable HTTP); call __unlock_blockchain_analysis__ once; all tools need a chain_id string. lib/mcp.ts

Architecture

flowchart TD
    U(["Browser · chat UI"])
    A["Agent orchestrator<br/>tool-calling loop · DeepSeek → 0G Compute"]
    TG["The Graph<br/>Token API · Subgraph gateway"]
    HED["Hedera<br/>Mirror Node · HCS"]
    BS["Blockscout<br/>REST · MCP"]
    PR["Provenance recorder<br/>question · queries · rows · answer"]
    ZG[("0G Storage<br/>tamper-evident rootHash")]

    U -- "POST /api/ask" --> A
    A -- "routes per question" --> TG
    A --> HED
    A --> BS
    A -- "narrative + chart" --> U
    A --> PR
    PR --> ZG
    ZG -. "receipt 0g://…" .-> U

    classDef pillar fill:#e6f1fb,stroke:#185fa5,stroke-width:2px,color:#042c53;
    classDef enh fill:#f1efe8,stroke:#888780,color:#2c2c2a;
    class TG,HED,ZG pillar
    class BS enh
Loading

$15k pillars — The Graph · 0G · Hedera — highlighted; Blockscout is a non-sponsor enhancement. Provenance backend is local (fast dev) or 0g (on-chain).

Status / roadmap (event 2026-09-13)

  • W1 ✅ agent spine + Graph Token tool + UI + provenance + chart
  • W3-4 ✅ Graph depth: query_subgraph (gateway GraphQL), agent visibly routes among data sources
  • W5-6 ✅ 0G Storage on-chain provenance (proven, real rootHash); 0G Compute deferred to submission (env-swap)
  • Hederaquery_hedera (Mirror Node) — adds the $15k Hedera pillar, keyless
  • Blockscout MCP ✅ wired (real MCP tools) — kept as a demo enhancement (not a 2026 sponsor)
  • W9-12 demo hardening: deterministic questions.json, caching, recorded 2-4min video, per-bounty writeups; reconfirm each sponsor's judging criteria (~Aug, currently "coming soon"); git init public repo with commit history

Layout

app/    page.tsx (UI) · api/ask/route.ts (endpoint)
lib/    agent.ts · llm.ts · canonical.ts · provenance.ts · provenance0g.ts · mcp.ts · types.ts
        tools/{graphToken,subgraph,hedera,blockscout,registry}.ts
scripts/ smoke.ts (CLI) · gen-zg-wallet.mjs · catch-*.mjs (browser→disk secret catchers)
docs/    blockscout-mcp-submission.md
questions.json   deterministic demo set

About

ChainSight — natural-language on-chain analyst with verifiable AI. Agent routes across The Graph, Hedera, and Blockscout; provenance notarized to 0G Storage. ETHOnline 2026.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors