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)
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.
Scaffold a subgraph against your contract's ABI and address
graph init --from-contract 0xYourContractAddress --abi ./YourContract.jsonWhen prompted for the network, you need Lumia's network identifier as registered with The Graph.
Define events and handlers
Define the events you want indexed in schema.graphql and the corresponding handlers in the generated mapping file (AssemblyScript).
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
Last updated
Was this helpful?