An open API service indexing awesome lists of open source software.

https://github.com/gitcoinco/grants-stack-indexer

Grants Stack Indexer
https://github.com/gitcoinco/grants-stack-indexer

Last synced: 12 months ago
JSON representation

Grants Stack Indexer

Awesome Lists containing this project

README

          

# Grants Stack Indexer

The Grants Stack Indexer is a tool that indexes blockchain events generated by [Allo contracts](https://github.com/Allo-Protocol/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](https://github.com/boudra/chainsauce) and is designed to work with any EVM-compatible chain.

The indexer data is used by [Grants Stack](https://github.com/gitcoinco/grants-stack) as a data layer.

Indexer user docs featuring [sample queries](https://docs.allo.gitcoin.co/indexer/application) can be found at [docs.allo.gitcoin.co](https://docs.allo.gitcoin.co/indexer).

## 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](src/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

```bash
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

```bash
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](./docs/deploy-to-fly.md).

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](https://github.com/gitcoinco/grants-stack-indexer/blob/main/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.