indexer-filters

Filters blockchain events by indexed parameters using static, dynamic, and per-chain where clauses.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Indexing every event on a chain wastes processing time when you only care about specific addresses or parameter values. This Skill shows how to use the HyperIndex where handler option to filter events by indexed parameters, cutting down the volume of events your handlers must process.

Core Features & Use Cases

  • Static Filters: Pass a single object (AND across fields) or an array of objects (OR across entries) to match indexed event parameters like from and to addresses.
  • Dynamic Per-Chain Filters: Use a function receiving { chain } to return different filters per chain ID, skip chains entirely with return false, or filter by dynamically registered contract addresses via chain.<ContractName>.addresses.
  • Per-Event startBlock: Set block.number._gte (or block.height._gte on Fuel) to override the contract-level start_block for a single event.
  • Use Case: You index ERC20 Transfer events across chains 100 and 137 but only care about transfers involving a whitelist of addresses. Use the function form of where to return OR'd param filters per chain and skip all other chains.

Quick Start

Ask the AI to add a where filter to your ERC20 Transfer event handler so it only processes transfers involving your whitelisted addresses on specific chains.

Frequently Asked Questions about indexer-filters

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

FAQPage Schema
How do I filter blockchain events by indexed parameters in HyperIndex?

Use the `where` option in `indexer.onEvent` with a `params` object matching indexed event parameters. A single object ANDs fields together, while an array of objects ORs multiple filter combinations.

How do I apply different event filters per chain?

Pass a function to `where` that receives `{ chain }` and returns a filter based on `chain.id`. Return `false` to skip a chain entirely, `true` to accept all events, or a `{ params }` object to filter.

Can I filter events by dynamically registered contract addresses?

Yes. Inside the `where` function, access `chain.<ContractName>.addresses` to get the indexed addresses of the event's own contract on that chain and use them as filter values in your params entries.

How do I set a startBlock for a single event instead of the whole contract?

Add `block: { number: { _gte: startBlock } }` as a sibling of `params` in the `where` filter. This overrides the contract-level `start_block` from config.yaml for that event only. On Fuel, use `block.height._gte` instead.

What are the limitations of the where event filter?

Filters only apply to indexed event parameters, and only `_gte` is accepted for block ranges. The `block` filter must sit at the top level of `where`, not inside params array entries, and SVM has no event handlers.