indexer-factory

Registers dynamically deployed factory contracts for event indexing in Envio HyperIndex.

546|55|Updated May 24, 2024
One-click install
npx skills add https://github.com/enviodev/hyperindex --skill indexer-factory
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: indexer-factory
Source: https://github.com/enviodev/hyperindex/tree/main/packages/cli/templates/static/shared/.claude/skills/indexer-factory
Command: npx skills add https://github.com/enviodev/hyperindex --skill indexer-factory

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Indexing contracts created at runtime by factory contracts (like Uniswap pairs) is impossible with static address configuration, since the addresses don't exist when the indexer starts. This Skill shows how to register those contracts dynamically so their events are captured from the moment of creation.

Core Features & Use Cases

  • Dynamic Contract Registration: Use indexer.contractRegister with context.chain.<ContractName>.add(address) to register contracts that have no address in config.yaml.
  • Async Registration Logic: Perform external calls (e.g., checking a contract version) to decide which contract type to register for a given address.
  • Same-Block Coverage: Automatically index all events from a newly registered contract within the same block it was created, including earlier transactions in that block.
  • Use Case: Index every Uniswap V2 pair's Swap and Sync events by listening to the factory's PairCreated event and registering each new pair address at runtime.

Quick Start

Ask the AI to set up a HyperIndex config and handlers that register Uniswap-style factory-created contracts dynamically using contractRegister.

Frequently Asked Questions about indexer-factory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I index contracts created by a factory contract in Envio?

Define the child contract in config.yaml without an address, then use indexer.contractRegister on the factory's creation event to call context.chain.<ContractName>.add(address). The indexer will then track all events from each registered address.

How to register dynamic contracts with contractRegister in HyperIndex?

Call indexer.contractRegister with the factory contract and event name, then inside the handler use context.chain.<ContractName>.add(event.params.address). The contract name must match the name field in config.yaml.

Does HyperIndex index events from the same block a contract is created?

Yes. When a dynamic contract is registered, the Envio indexer indexes all events from that contract in the same block where it was created, including events from earlier transactions in that block.

Can I choose which contract to register based on external data?

Yes. The contractRegister handler is async, so you can make external calls, such as checking a contract version, and conditionally register different contract types based on the result.

Why does my dynamic contract config have no address field?

Contracts registered dynamically must omit the address in config.yaml because their addresses are unknown until runtime. The address is supplied later through context.chain.<ContractName>.add(address) during contractRegister.