Skip to content

Add serve-hedera-contract-as-graphql snippet — bridge Hedera into The Graph tooling - #52

Open
mrarejimmyz wants to merge 1 commit into
hedera-dev:mainfrom
mrarejimmyz:add-hedera-graphql-snippet
Open

mrarejimmyz wants to merge 1 commit into
hedera-dev:mainfrom
mrarejimmyz:add-hedera-graphql-snippet

Conversation

@mrarejimmyz

Copy link
Copy Markdown

Summary

  • Adds serve-hedera-contract-as-graphql/ — self-contained snippet that exposes any Hedera contract as a standardized-subgraph GraphQL endpoint via Mirror Node
  • ~200 LOC total; runs with npm install && node index.mjs
  • Ships an ERC-4626 preset — any vault emitting Deposited(address indexed, uint256, uint256) + Withdrawn(...) gets the full Messari-standardized query surface (pools, transactions, _meta) for free

Why

The Graph doesn't index Hedera. I verified this against the official networks registry: 129 EVM chains supported, Hedera not among them (as of 2026-09-07). Any Hedera dApp that wants "subgraph playground for our users", "AI agent that queries our contract state", or just "GraphQL instead of REST" ends up hand-rolling a Mirror Node client.

Meanwhile Hedera Mirror Node already indexes every contract event on Hedera for free with sub-second consensus. All the raw material is there — nothing turns it into subgraph-shaped GraphQL. This snippet is the missing glue.

Result: all Graph-native tooling — subgraph MCP servers, playgrounds, GraphiQL, subgraph explorers — works over Hedera contracts unchanged.

What ships

  • index.mjs — Express server exposing POST /graphql + GET /graphql/sdl
  • adapter.mjs — self-contained bundled adapter (Mirror Node client + GraphQL executor + ERC-4626 preset)
  • README.md — 60-second quickstart + "same query, both backends" demo
  • package.json — only express + graphql peer deps
  • .env.exampleHEDERA_NETWORK, VAULT_ADDRESS, PORT

Default VAULT_ADDRESS points at a live public testnet vault so the snippet runs out-of-the-box with real data — no faucet or contract deploy needed.

Verified working

$ npm install && node index.mjs
hedera-graphql-adapter live on http://localhost:4000
  vault: 0xe7E6fEDce9d72D112137B631E8D51831D30729A9

$ curl -sX POST http://localhost:4000/graphql -H 'content-type: application/json' \
    -d '{"query":"{ pools { id network totalNav memberCount } transactions(first: 2) { type actor amount } _meta { block { number } deployment } }"}'
{"data":{
  "pools":[{"id":"0xe7e6…29a9","network":"hedera-testnet","totalNav":"987363187","memberCount":3}],
  "transactions":[{"type":"DEPOSIT","actor":"0xe615…8a38","amount":"70000000"},...],
  "_meta":{"block":{"number":40208181},"deployment":"hedera-mirror-adapter:0xe7e6fed…"}
}}

Same query works against a Studio-hosted subgraph on any of the 129 supported EVM chains — one schema, N backends. That's the "one query pattern spans many protocols" pattern extended to include Hedera.

Extended library

The snippet bundles the adapter inline to stay self-contained per repo convention. The upstream package with more presets, TypeScript types, and optional HCS-attestation add-ons for AI-agent trust chains lives at:

Test plan

  • npm install succeeds on fresh clone
  • node index.mjs starts server on :4000
  • POST /graphql returns real vault state from Mirror Node
  • GET /graphql/sdl returns the standardized schema
  • Bit-identical shape vs Studio subgraph (parity verified against https://api.studio.thegraph.com/query/1758819/zkward/v0.1.1)
  • No external services required — fully self-contained

Related

Bridges Hedera Mirror Node into standardized-subgraph GraphQL shape so
Hedera contracts can be queried by any Graph-native tool (subgraph MCP
servers, playgrounds, GraphiQL, subgraph explorers).

The Graph doesn't index Hedera (verified via the official networks
registry — 129 EVM chains supported, Hedera not among them). Mirror
Node already indexes every contract event with sub-second consensus,
but speaks REST/JSON. This snippet is the ~200 LOC of glue.

- Self-contained: `npm install && node index.mjs` — no external services
- ERC-4626 preset: any vault that emits Deposited/Withdrawn events gets
  the whole Messari-standardized query surface for free
  (pools, transactions, _meta)
- Runs out-of-the-box against a live ZkWard testnet vault; set
  VAULT_ADDRESS to point at your own contract
- Same query shape works against a Studio-hosted subgraph AND this
  endpoint — proof that the schema abstracts over indexing backends

Extended library with more presets + HCS-attestation add-ons lives at
github.com/ZkVanguard/zkward-ethglobal (packages/hedera-graphql-adapter).
@wiz-665387e357

wiz-665387e357 Bot commented Sep 7, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities 2 Medium
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 3 Low
Software Management Finding Software Management Findings -
Total 2 Medium 3 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant