Skip to content

a compact graph indexer stack for parity substrate, polkadot, kusama

License

Notifications You must be signed in to change notification settings

playzero/substrate-graph

Repository files navigation

Substrate Graph

What

A compact indexer for @paritytech substrate based nodes providing a graphql interface.

Realtime

Why

Interacting, archiving and querying transactions on blockchain nodes can become expensive. An indexer provides unified access to historic data. Parsing and creating complex interfaces with this data is cumbersome when using REST, GraphQL offers the latest and greatest to query, subscribe and mutate data leading to efficient data structures and therefore hopefully cleaner code and better (D)Apps.

How

We have built a docker-compose to fire up a stack as pictured below:

Schema

Getting started

This is tested on macOS and Linux. Experience may vary on Windoze.

Requirements:

  • docker
  • docker-compose
  • text editor
  • (make)

If you want to build/edit frontend or archiver:

  • rust

Run it

  1. clone the repo git clone https://github.com/playzero/substrate-graph && cd substrate-graph
  2. setup your env vars or start with a clone of .env.example ('')
  3. setup your archiver config and chainspec in ./config
  4. docker-compose up
  5. log in to hasura localhost:18080 and enter your admin password
  6. on the data tab, add all untracked items
  7. have phun in graphiql!

All data will be persisted in your local repository ./data. Inside all services will store their data, like postgres, substrate/polkadot/kusama. To restart fresh, when things go south, make sure to clean up the contents of the data folder.

Frontend

An example app has been created in packages/substrate-graph-frontend. To get started with it, from your substrate-graph dir, get the submodules with git submodule init && git submodule update.

After that you may build the frontend app like this and run it afterwards: cd ./packages/substrate-graph-frontend && yarn, then yarn start.

if everything runs smoothly, you will see a graphql subscription rendering into a block number and a small table showing recent blocks and contents.

Substrate-Archive

Currently an older archive version is used for building the docker images, which are used in the compose file. They are based on code found at packages/substrate-archive. This will be updated but ofc you may use your own images here, if you so wish.

Status

  • add polkadot

  • add custom substrate nodes (substrate node template)

  • add config examples

  • add docker-compose

  • add subscriptions

  • add frontend example

  • add monitoring dashboard

  • add load balancer example

  • kubernetes / helm chart

  • add crawler / harvester

  • add

Discuss

Join us on Discord: ZERO on Discord

Credits

Further Reading