Subgraph
Service for easily indexing data emitted by the rage trades contracts. The subgraph essentially queries the blockchain for all the event data emitted by the rage trade contracts, these events are indexed and modified to be queried, as graphl, by an application.
It will serve as a real time backend and data store for executing complex calculations and indexing historical data that cannot be efficiently consumed directly from the contracts. For a more in depth understanding, read thegraph docs.
Links
Usage (for developers)
Before you deploy, you'll need to get an access key from thegraph and run npm run auth
Important modules
- schema.graphql Describes all the enitities, and their fields, ie the data you want to fetch from the subgraph, also documents what each field is used for.
- subgraph.yaml The config for the entire project, it describes
- which events and you want to index, the signature for the index
- which functions will handle the incoming event data
- Contract metadata, including name, abi and address etc...
- src The source code, written in assemblyscript that handles all the incoming data and processes it. We run some complex indexing logic to derive a lot of values and transform the data into formats that can easily consumed by the frontend. The code makes use of various assemblyscript apis provided by the @graphprotocol/graph-ts package.
Reading The Schema
For a complete definition of the schema, you can use the thegraph.com playground, it will include all entitties you can query.
When you click on an entity, you can see all the fields on that entity with a brief explanaition on what that field represents. On the left you'll find a code block where you can test out your queries, some of these example queries are shown in the example queries section below.


Example Queries