indexer-blocks

Implements block-level handlers that process every block or every Nth block in Envio indexers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Indexing time-series data, periodic snapshots, or block-level aggregations requires processing blocks directly rather than contract events, and configuring per-chain block ranges and strides correctly is error-prone.

Core Features & Use Cases

  • Block Handler Registration: Uses the indexer.onBlock API to process every block or every Nth block without a contract address or config.yaml entry.
  • Per-Chain Filtering: The where predicate supports block number ranges (_gte, _lte) and stride (_every) per chain, with a TypeScript exhaustiveness check via switch on chain.id.
  • Multi-Ecosystem Support: Covers Fuel (block.height filters) and SVM (indexer.onSlot with slot filters) variants.
  • Use Case: Build a block snapshot entity that records every 100th block on Ethereum mainnet starting at block 18000000 and every 50th block on Base, storing results via the handler context entity API.

Quick Start

Add a block handler to my Envio indexer that snapshots every 100th block on Ethereum mainnet starting from block 18000000.

Frequently Asked Questions about indexer-blocks

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

FAQPage Schema
How do I process every block in an Envio indexer?

Use the indexer.onBlock API with a name and a handler function. It self-registers without a config.yaml entry or contract address, and the handler context exposes the same entity API as event handlers.

How to index every Nth block with onBlock filters?

Return a filter like {block: {number: {_gte: 18000000, _every: 100}}} from the where predicate. The _every stride aligns relative to _gte, so only blocks satisfying (blockNumber - _gte) % _every === 0 are processed.

Does indexer.onBlock work on Fuel and Solana (SVM)?

Fuel uses the same indexer.onBlock API but filters by block.height instead of block.number. SVM uses indexer.onSlot with a {slot: {_gte, _lte, _every}} filter and a handler receiving {slot, context}.

What is the difference between onBlock filters and onEvent filters?

Event filters via indexer.onEvent accept only _gte on block.number for per-event startBlock. The _lte and _every options are reserved for onBlock, which supports full range and stride filtering.

Why does TypeScript error in my onBlock where function?

The switch on chain.id uses a default branch assigning chain.id to a never-typed variable. If a new chain is added to config.yaml but not handled, the exhaustiveness check fails at compile time until you add a case for it.