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
- Host: GitHub
- URL: https://github.com/gitcoinco/grants-stack-indexer
- Owner: gitcoinco
- Created: 2023-03-15T11:03:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-12T12:51:06.000Z (about 2 years ago)
- Last Synced: 2024-04-13T22:04:52.850Z (about 2 years ago)
- Language: TypeScript
- Homepage: https://grants-stack-indexer.gitcoin.co/
- Size: 2.57 MB
- Stars: 23
- Watchers: 8
- Forks: 17
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
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.