/allo-indexer

Allo Protocol Indexer for Grants Stack

Primary LanguageTypeScript

Allo Protocol Indexer

The Allo Protocol Indexer is a tool that indexes blockchain events generated by Allo contracts and serving 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 to show stats and allocate matching funds.

Indexed Data

Access indexed data through this URL: https://indexer-grants-stack.gitcoin.co

The indexed data follows this structure:

/{chainId}/rounds.json
/{chainId}/prices.json
/{chainId}/projects.json
/{chainId}/rounds/{roundId}/projects.json
/{chainId}/rounds/{roundId}/projects/{projectId}/votes.json
/{chainId}/rounds/{roundId}/projects/{projectId}/contributors.json
/{chainId}/rounds/{roundId}/applications.json
/{chainId}/rounds/{roundId}/applications/{applicationIndex}/votes.json
/{chainId}/rounds/{roundId}/votes.json
/{chainId}/rounds/{roundId}/contributors.json

The indexer is monitoring the following chains with their respective chain IDs:

  • Ethereum Mainnet: 1
  • Ethereum Goerli Testnet: 5
  • Optimism: 10
  • Fantom: 250

How to run?

npm install
npm run build
npm start # run the HTTP server and all the indexers for all chains

You can run specific indexers:

npm run index:mainnet
npm run index:goerli
npm run index:fantom
npm run index:optimism

Development

npm run dev # Run the Typescript compiler on watch mode
npm run build # Compile the code
npm run lint # Lint the code

Developing the indexer

Please make sure you set the environment variables before running, find a .env template in .env.example

Each indexer has a dev: prefix which will watch for code changes and re-run the indexer with an empty data directory.

npm run dev:index:mainnet

Then check the new files generated under data/1.

HTTP Server

The npm run serve command runs a static HTTP server to serve the JSON files inside /.data.

Indexer arguments

The indexer updates to the current last block and exits, use the follwing options to change it's behaviour:

npm run index:mainnet -- --to-block=16833357 # run only to the specified block, useful to maximize cache usage
npm run index:mainnet -- --follow # follow the blockchain, this run as a long running process
npm run index:mainnet -- --clear # run from empty data, it will index from the beginning
npm run index:mainnet -- --no-cache # run without a cache

Deployment

The indexer is currently automatically deployed on Fly.io from the main branch. We reindex everything from scratch on each deploy, we only persist the cache, which includes events and IPFS data.

The following commands might be useful for monitoring production:

fly status # show general status of the app, all VMs and their status
fly logs # check logs of running VM, it also shows logs of deployments in progress
fly ssh console # open a console to the runnning VM