Please refer to the documentation website for a thorough guide on all Envio indexer features
With HyperIndex, developers can index contracts deployed from factory contracts without specifying their addresses in advance. A common example of the factory pattern is Uniswap V3, which deploys new pool contracts through its factory.
This example demonstrates how to index Uniswap V3 Pools created by the Uniswap V3 Factory on Ethereum Mainnet.
For more information, see the dynamic contracts documentation.
To index contracts deployed from a factory, use the contractRegister handler on the event that emits the deployed contract’s address. Within the handler, use the context object to register the new contract with the indexer.
Example:
<contract-name>.<event-name>.contractRegister(({ event, context }) => {
context.add<your-contract-name>(<address-of-the-contract>);
});In the case of Uniswap V3 Factory, the handler looks like this:
UniswapV3Factory.PoolCreated.contractRegister(({ event, context }) => {
context.addUniswapV3Pool(event.params.pool);
});Before running the indexer locally, make sure you have the following installed:
Add your Envio API key to the .env file, then start the indexer:
pnpm devIf you make changes to config.yaml or schema.graphql, regenerate the type files:
pnpm codegenWhile indexer is running, visit the Envio Console(https://envio.dev/console) to open the GraphQL Playground and query your indexed data.