For the complete documentation index, see llms.txt. This page is also available as Markdown.

Index contract events with The Graph

You want to index contract events on Lumia so your app can query historical/aggregated data instead of scanning logs itself.

Who this is for: developers who need indexed, queryable contract data. Prerequisites: a deployed, verified contract on Lumia; Networks & Endpoints.

Steps (confirm network support before deploying)

1

Install the Graph CLI

Consult The Graph's own current published docs for the package name and version; that's their product, not Lumia's.

2

Scaffold a subgraph against your contract's ABI and address

graph init --from-contract 0xYourContractAddress --abi ./YourContract.json

When prompted for the network, you need Lumia's network identifier as registered with The Graph.

3

Define events and handlers

Define the events you want indexed in schema.graphql and the corresponding handlers in the generated mapping file (AssemblyScript).

4

Deploy

Deploy to a self-hosted Graph Node pointed at Lumia's RPC (see /reference/networks), or to The Graph's hosted/network service if Lumia is a supported network there.

Verify it worked

Query the deployed subgraph's GraphQL endpoint for an entity you know exists on-chain (e.g. a specific event from a transaction you already confirmed on the explorer) and confirm the response matches.

{
  yourEntities(first: 5, orderBy: blockNumber, orderDirection: desc) {
    id
    blockNumber
  }
}

Troubleshooting

graph init has no Lumia network option

This is expected until network registration is confirmed; fall back to a self-hosted Graph Node against Lumia's RPC.

Subgraph syncs but returns no entities

Check your handler's event signature against the contract's actual emitted event. A mismatched ABI is the most common cause.

Last updated

Was this helpful?