This template provides a basic framework for implementing an on-chain governance indexer. It's configured to listen to specific governance events in smart contracts on blockchain networks and index these events for easier querying and analysis.
- Multi-blockchain network configuration
- Support for common governance events
- Easy to extend and customize
Before starting, ensure you have the necessary tools installed, including Node.js, npm/yarn, and Git.
-
Clone the Repository:
git clone [https://github.com/developerfred/envio-indexer-template-gov] cd indexer-on-chain-governance
-
Install Dependencies:
npm install
-
Environment Setup:
- Copy the
.env.example
file to.env
. - Fill in the required environment variables in the
.env
file.
- Copy the
This template is pre-configured to listen for governance events on specific contracts. You can modify these settings in the network configuration file.
- id: Identifier of the blockchain network chain.
- rpc_config: RPC access point configuration.
- start_block: Initial block from which the indexer starts listening to events.
- contracts: List of contracts and events to be monitored.
networks:
- id: 1
rpc_config:
url: https://eth.llamarpc.com
start_block: 12422079
contracts:
- name: Governance
abi_file_path: abis/GovernanceContract.json
address:
- 0x9d4c63565d5618310271bf3f3c01b2954c1d1639
handler: src/EventHandlers.ts
events:
- event: ProposalCanceled(uint256 proposalId)
requiredEntities:
- name: EventsSummary
# ... [more events]
To start the indexer, run the following command:
npm start
This will initiate the process of listening to the configured events and index them as defined in the event handlers.
You can customize this template by adding new events or modifying existing event handlers as needed. The event handlers are defined in src/EventHandlers.ts
.