Skip to content

gitcoinco/grants-stack-indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grants Stack Indexer

The Grants Stack Indexer is a tool that indexes blockchain events generated by Allo contracts and serves the data over HTTP in JSON format. The data is organized in a specific structure that enables easy access to different parts of the protocol. The indexer is built using Chainsauce and is designed to work with any EVM-compatible chain.

The indexer data is used by Grants Stack as a data layer.

Indexer user docs featuring sample queries can be found at docs.allo.gitcoin.co.

API

Access indexed data through the GraphQL endpoint at:

https://grants-stack-indexer-v2.gitcoin.co/graphql

Use the GraphiQL Playground to inspect the schema:

https://grants-stack-indexer-v2.gitcoin.co/graphiql

Indexed chains are defined in config.ts.

Setup

Requires Node 18 minimum.

Copy .env.example to .env, review and optionally customize it.

To pick chains to index, set INDEXED_CHAINS to a comma-separated list of chain identifiers. Available chain identifiers can be found in src/config.ts.

Running in development

cp .env.example .env
docker-compose up -d
npm install
npm run build

npm run dev

# you can also pass arguments to the dev script

npm run dev -- --drop-db # drop the database before indexing
npm run dev -- --from-block=latest # start indexing from the last block
npm run dev -- --from-block=12345 # start indexing from the 12345th block
npm run dev -- --run-once # index and exit without watching for events
npm run dev -- --no-cache # disable cache
npm run dev -- --log-level=trace # set log level
npm run dev -- --port=8081 # start web service on a given port

Running in production

npm install
npm run build
npm run start # this will sync to the last block and then run the http server

Or use the provided Dockerfile.

Deployment

Check out this guide to deploy your own indexer on Fly.io.

We're currently continuously deploying the main branch into Fly.

There are a few things to consider when it comes to deploying your changes:

  • Deployments resume indexing from the last indexed block, which means that your changes will only apply to new blocks, and migrations are not applied
  • If you need to change the database schema or change an event handler retroactively, you need to increment the CHAIN_DATA_VERSION constant found in src/config.ts, on deployment this will automatically create a new schema in Postgres and reindex all events. Note that deployments that reindex will take longer.

Releases

No releases published

Packages

No packages published

Languages