Envio indexer for DAO ecosystem data. Indexes on-chain events and exposes them via GraphQL API.
# 1. Setup
pnpm install
# 2. Run with MAINNET (uses HyperSync - fast!)
export $(grep -v '^#' .env.mainnet | xargs) && pnpm dev
# 3. Open GraphQL Playground: http://localhost:8080
# Password: testing# 1. Get a free RPC API key from https://rpc.rootstock.io/
# 2. Edit .env.dev - update ENVIO_RPC_URL with your API key
# 3. Run: export $(grep -v '^#' .env.dev | xargs) && pnpm devEnvio-based indexer for the DAO ecosystem. Currently indexes governance data from the Governor contract, with architecture designed to support additional data sources (staking, vault history, rewards, etc.) through configuration.
ProposalCreated- Creates proposal entity with quorum fetched via RPCVoteCast/VoteCastWithParams- Aggregates vote counts, stores individual votesProposalCanceled/ProposalExecuted/ProposalQueued- Updates terminal state flags
- Node.js >= 22.0.0
- pnpm >= 9.15.0
- Docker Desktop (must be running)
- Rootstock RPC API Key (free) - get one at https://rpc.rootstock.io/
- Required because the public node (
public-node.testnet.rsk.co) doesn't supporteth_getLogs
- Required because the public node (
- Install dependencies:
pnpm install- Configure environment:
cp .env.example .env.dev-
Get RPC API Key (required):
- Go to https://rpc.rootstock.io/
- Sign up / Log in with GitHub
- Create API key for Testnet
- Update
.env.dev:ENVIO_RPC_URL=https://rpc.testnet.rootstock.io/<YOUR_API_KEY>
-
Run locally (Docker must be running):
export $(grep -v '^#' .env.dev | xargs) && pnpm dev- Access GraphQL Playground: http://localhost:8080
- Admin password:
testing
- Admin password:
Note: The
export $(grep ...)pattern filters out comments and exports variables to the shell.
| Variable | Description | Example |
|---|---|---|
ENVIO_CHAIN_ID |
Chain ID | 31 (Rootstock Testnet) |
ENVIO_START_BLOCK |
Block to start indexing from | 7290000 (recent) or 5512037 (all history) |
ENVIO_GOVERNOR_ADDRESS |
Governor contract address | 0xB1A39B8f57A55d1429324EEb1564122806eb297F |
ENVIO_RPC_URL |
RPC endpoint (with API key) | https://rpc.testnet.rootstock.io/<YOUR_API_KEY> |
ENVIO_API_TOKEN |
HyperSync API token (optional) | your-api-token |
Tip: Use a recent
ENVIO_START_BLOCK(e.g., last week) for fast initial sync during development. Use5512037for full proposal history.
The indexer supports two data sources:
- RPC Mode (default): Uses standard RPC endpoint. Works on all chains but slower sync.
- HyperSync Mode: Uses Envio's HyperSync for up to 2000x faster syncing.
| Chain | Chain ID | HyperSync Support |
|---|---|---|
| Rootstock Mainnet | 30 | Yes |
| Rootstock Testnet | 31 | Pending |
When HyperSync becomes available for your chain:
-
Get an API token at https://envio.dev/app/api-tokens
-
Add token to your
.envfile:
ENVIO_API_TOKEN=your-api-token-here- Update
config.yaml- comment outrpc_configand uncommenthypersync_config:
networks:
- id: ${ENVIO_CHAIN_ID}
start_block: ${ENVIO_START_BLOCK}
# HyperSync (uncomment when available)
hypersync_config:
url: https://${ENVIO_CHAIN_ID}.hypersync.xyz
bearer_token: ${ENVIO_API_TOKEN}
# RPC fallback (comment out when using HyperSync)
# rpc_config:
# url: ${ENVIO_RPC_URL}- Restart the indexer:
pnpm envio stop
export $(grep -v '^#' .env.dev | xargs) && pnpm dev- Create environment file:
cp .env.example .env.mainnet- Update values:
ENVIO_CHAIN_ID=30
ENVIO_START_BLOCK=<deployment_block>
ENVIO_GOVERNOR_ADDRESS=<mainnet_governor_address>
# For mainnet, HyperSync is available - no RPC needed
# Or use: ENVIO_RPC_URL=https://rpc.mainnet.rootstock.io/<YOUR_API_KEY>- Run with new environment:
export $(grep -v '^#' .env.mainnet | xargs) && pnpm devOnce running, access the GraphQL playground at http://localhost:8080.
query GetProposals {
Proposal(order_by: { createdAt: desc }, limit: 10) {
id
proposalId
proposer
description
voteStart
voteEnd
votesFor
votesAgainst
votesAbstains
quorum
isCanceled
isExecuted
isQueued
createdAtBlock
}
}{
"data": {
"Proposal": [
{
"id": "12345",
"proposalId": "12345",
"proposer": "0x1234...5678",
"description": "# Proposal Title\n\nDescription here...",
"voteStart": "7000000",
"voteEnd": "7100000",
"votesFor": "1000000000000000000000",
"votesAgainst": "500000000000000000000",
"votesAbstains": "100000000000000000000",
"quorum": "4000000000000000000000",
"isCanceled": false,
"isExecuted": false,
"isQueued": false,
"createdAtBlock": "6900000"
}
]
}
}Each environment runs as a separate Envio hosted indexer, deployed via a dedicated git branch. See docs/deployment-architecture.md for the full rationale.
| Branch | Indexer Name | Governor | Chain | Frontend Profile |
|---|---|---|---|---|
dev-index |
dao-envio-indexer-dev |
0xB1A39B8f... |
31 (testnet) | dev |
rc-testnet |
dao-envio-indexer-rc-testnet |
0xb77ab007... |
31 (testnet) | release-candidate-testnet |
The Envio hosted service uses a git-based workflow (similar to Vercel). Pushing to a deployment branch triggers a redeploy automatically.
- Create a deployment branch (if new environment):
git checkout main && git checkout -b <branch-name>-
Update
config.yamlwith environment-specific values (name, governor address, RPC key, start block). -
Push to trigger deployment:
git push origin <branch-name>- Create the indexer in the Envio dashboard: connect the repo, set the deployment branch, and monitor via the Logs tab.
Important: Each deployment needs its own RPC API key (free at https://rpc.rootstock.io/) to avoid rate-limit contention. See docs/deployment-architecture.md for details.
- Update
config.yamlwith new event signatures - Run
pnpm codegento regenerate types - Add handler in
src/EventHandlers.ts
- Add ABI to
abis/folder - Add contract definition to
config.yaml:
contracts:
- name: Governor
# existing config...
- name: Staking
abi_file_path: ./abis/Staking.json
handler: src/StakingHandlers.ts
events:
- event: 'Staked(address indexed user, uint256 amount)'
- event: 'Unstaked(address indexed user, uint256 amount)'- Add network binding:
networks:
- id: ${ENVIO_CHAIN_ID}
contracts:
- name: Governor
address: ${ENVIO_GOVERNOR_ADDRESS}
- name: Staking
address: ${ENVIO_STAKING_ADDRESS}- Create schema entities in
schema.graphql - Run
pnpm codegen - Implement handlers in new handler file
dao-envio-indexer/
├── abis/ # Contract ABIs
│ └── Governor.json
├── docs/
│ └── deployment-architecture.md # Deployment strategy & RPC constraints
├── src/
│ ├── EventHandlers.ts # Event handler implementations
│ └── effects/
│ └── quorumEffect.ts # Effect API for RPC calls
├── generated/ # Auto-generated (do not edit)
├── config.yaml # Envio configuration (template on main)
├── schema.graphql # GraphQL schema
├── .env.dev # DEV environment config (local only)
├── .env.example # Environment template
├── package.json
└── tsconfig.json
- Use a recent
ENVIO_START_BLOCKfor faster testing - When HyperSync becomes available for Rootstock Testnet, switch to it (2000x faster)
Check your ENVIO_START_BLOCK - proposals created before that block won't be indexed. Use 5512037 for full history.
- Keep indexer running (
pnpm dev) - In
dao-frontend/.env.dev, ensure:ENVIO_GRAPHQL_URL=http://localhost:8080/v1/graphql - Run frontend:
pnpm dev - Check response header
X-Source: source-0to confirm Envio is being used
MIT