the-graph
Skill1 starsChanged 25 days agoMITView on GitHub
The Graph indexes smart-contract events into a GraphQL API (a subgraph). Use this skill to build a subgraph with Graph CLI (graph init, schema.graphql, AssemblyScript mappings, graph codegen/build, graph deploy to Subgraph Studio), query a subgraph from a frontend (fetch, graphql-request, urql) with an API key, write GraphQL filters/pagination/ordering, or pick network names for Unichain, Arc and World Chain.
- Reads credentials
- Installs packages
- Sends data out
In this repository55 other files it gives its agents.
- aaveSkill
- agentkitSkill
- alchemySkill
- backboardSkill
- biconomySkill
- blockscoutSkill
- daimoSkill
- duneSkill
- dynamicSkill
- easSkill
- ensoSkill
- envioSkill
- fetch-aiSkill
- goldskySkill
- hardhatSkill
- litSkill
- livepeerSkill
- morphoSkill
- namespace-53d629Skill
- neynarSkill
- olasSkill
- onramp-moneySkill
- openzeppelinSkill
- pimlicoSkill
- pinataSkill
- ponderSkill
- privySkill
- pushSkill
- quicknodeSkill
- reclaimSkill
- reownSkill
- requestSkill
- safeSkill
- scaffold-ethSkill
- signSkill
- sponsor-chainsSkill
- superfluidSkill
- tenderlySkill
- thirdwebSkill
- track-0gSkill
- track-1inchSkill
- track-arcSkill
- track-arkivSkill
- track-chainlinkSkill
- track-definitiveSkill
- track-efSkill
- track-ensSkill
- track-hederaSkill
- track-uniswapSkill
- track-whitechainSkill
- track-worldSkill
- transakSkill
- web3authSkill
- xmtpSkill
- zerodevSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Create a subgraph in Subgraph Studio: connect a wallet, click Create a Subgraph, and note its slug and deploy key.
- Very specific: line 29
If you leave out --abi, the CLI tries to fetch the ABI from an explorer.
- Very specific: line 50
Run it with npx tsx --env-file=.env query.ts.
- Distinctive: line 70
Read the docs index first: https://thegraph.com/llms.txt.
- Very specific: line 72
Check versions first: npm view @graphprotocol/graph-cli version, npm view @graphprotocol/graph-ts version.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
The Graph
The Graph turns contract events into a GraphQL API. You write a subgraph: a manifest (subgraph.yaml), a schema (schema.graphql) and AssemblyScript mappings. You deploy it to Subgraph Studio, and your app queries it over HTTP.
Use it when your app needs lists, history, sorting or totals over on-chain events (a feed of trades, a leaderboard, balances per user). Do not use it to read one value from one contract: a plain eth_call (viem) is simpler. Subgraphs index events, so make sure your contract emits the events you need.
Quickstart
- Create a subgraph in Subgraph Studio: connect a wallet, click Create a Subgraph, and note its slug and deploy key.
- Install the CLI (Node >= 20.18.1):
npm i -g @graphprotocol/graph-cli@0.98.1, then check withgraph --version. - Scaffold from a deployed contract. The interactive
graph initasks for the same values. Note that the--productflag from older docs no longer exists:
If you leave outgraph init my-subgraph my-subgraph --protocol ethereum \ --from-contract <CONTRACT_ADDRESS> --network unichain-testnet \ --abi ./MyContract.json --contract-name MyContract \ --start-block <DEPLOY_BLOCK> --index-events--abi, the CLI tries to fetch the ABI from an explorer. - Edit
schema.graphqlandsrc/*.ts. Every@entitymust sayimmutable: trueorimmutable: false, or codegen fails. Then compile:cd my-subgraph && graph codegen && graph build - Deploy to Studio (you will be asked for a version label like
v0.0.1):graph auth <DEPLOY_KEY> graph deploy my-subgraph - Query it. Studio shows a dev query URL (
https://api.studio.thegraph.com/query/<ID>/<SLUG>/<VERSION>, limited to 3,000 queries/day). After you publish, use the gateway with an API key from Studio → API Keys:const res = await fetch(`https://gateway.thegraph.com/api/subgraphs/id/${process.env.SUBGRAPH_ID}`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.GRAPH_API_KEY}` }, body: JSON.stringify({ query: "{ transfers(first: 5, orderBy: blockNumber, orderDirection: desc) { id value } }" }), }); const json = await res.json(); // errors come back with HTTP 200, so check them if (json.errors) throw new Error(json.errors[0].message); console.log(json.data); - Run it with
npx tsx --env-file=.env query.ts. The.envholdsGRAPH_API_KEY=<YOUR_API_KEY>andSUBGRAPH_ID=<SUBGRAPH_ID>.
Full walkthrough with a complete subgraph (schema, mapping, manifest): references/quickstart.md.
Common tasks
- Scaffold a subgraph from a contract
- Schema + mapping: balances per account (load-or-create, @derivedFrom)
- Hourly/daily stats with timeseries and aggregations
- Deploy to Studio, versions, many networks (networks.json)
- Query from a frontend: fetch, graphql-request, urql, React, Next.js
- GraphQL patterns: filter, order, paginate, time-travel, _meta
- World Chain: no Studio support, so use Substreams or your own graph-node
- Token API and x402 (data without writing a subgraph)
- Errors and gotchas
- Network names for Unichain, Arc, World Chain
- Subgraph MCP server for Claude Code / Cursor
Before you write more code
- Read the docs index first: https://thegraph.com/llms.txt. The docs live at https://thegraph.com/docs/en/ (source: https://github.com/graphprotocol/docs). Useful pages: the GraphQL API reference, the AssemblyScript API and the manifest reference.
- Network names (
network:insubgraph.yaml) come from the networks registry. Check that your chain shows Subgraphs support on https://thegraph.com/docs/en/supported-networks/ before you build.graph initandgraph buildaccepted made-up names in testing, so they will not catch a typo for you. - Check versions first:
npm view @graphprotocol/graph-cli version,npm view @graphprotocol/graph-ts version.graph initmay pin an oldergraph-ts. This skill was tested with 0.38.2. - Some doc examples are older than the current CLI (the
--productflag,@entitywithoutimmutable,urqlwithoutexchanges). See errors.md. - When this skill and the official docs disagree, the docs win.
At ETHGlobal Mumbai
- Sponsor chains: Unichain (mainnet
unichain, Sepoliaunichain-testnet) and Arc (arc,arc-testnet) are supported in Subgraph Studio. World Chain (worldchain) has Substreams/Firehose only, with no Studio subgraphs. World Chain Sepolia, Hedera, 0G and Whitechain are not listed. Details: references/chains.md. - May help with the Uniswap Foundation, Arc and World tracks: dashboards, feeds and leaderboards over your contract's events. Check the tracks and their rules yourself: https://ethglobal.com/events/mumbai/prizes
- Help: The Graph Discord https://discord.gg/graphprotocol (linked from the docs). For deeper chain facts, see the
sponsor-chainsskill (npx skills add 0xvikram/backboard-skills --skill sponsor-chains).
About
Hand-written for Backboard (https://backboard.0xvikram.me), an independent project not affiliated with ETHGlobal or The Graph. Tested 2026-10-19 with @graphprotocol/graph-cli@0.98.1, @graphprotocol/graph-ts@0.38.2, graphql-request@7.4.0, graphql@16.14.2, @urql/core@6.0.3, urql@5.0.4.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

