en un clic
indexing-blocks
// Use when processing every block (or every Nth block) for time-series data, periodic snapshots, or block-level aggregations. onBlock API, interval option, and block handler context.
// Use when processing every block (or every Nth block) for time-series data, periodic snapshots, or block-level aggregations. onBlock API, interval option, and block handler context.
Use when writing or editing config.yaml. Chain/contract structure, addresses, start_block, event selection, field_selection, custom event names, env vars, address_format, schema/output paths, YAML validation, and deprecated options.
Use when making RPC calls, fetch requests, or any external I/O from handlers. Effect API with createEffect, S schema validation, context.effect(), preload optimization (handlers run twice), cache and rateLimit options.
Use when indexing contracts deployed by factory contracts at runtime. contractRegister API, dynamic contract config (no address), async registration, and same-block event coverage.
Use when filtering events by indexed parameters to reduce processing volume. eventFilters with static arrays, dynamic per-chain functions, contract address filtering, and conditional enable/disable.
Use when writing or editing event handlers. Handler registration, context API (entity CRUD, getWhere queries, chain, log), spread updates, indexer runtime API, and common pitfalls.
Use when deploying an indexer across multiple chains. Entity ID namespacing to avoid collisions, chain-specific configuration patterns, and the context.chain runtime API.
| name | indexing-blocks |
| description | Use when processing every block (or every Nth block) for time-series data, periodic snapshots, or block-level aggregations. onBlock API, interval option, and block handler context. |
Process every block (or every Nth block) using onBlock from generated. No contract address or config.yaml entry needed.
import { onBlock } from "generated";
onBlock(
{ name: "BlockTracker", chain: 1, interval: 100 },
async ({ block, context }) => {
context.BlockSnapshot.set({
id: `${block.number}`,
blockNumber: BigInt(block.number),
timestamp: BigInt(block.timestamp),
});
}
);
| Option | Type | Required | Description |
|---|---|---|---|
name | string | yes | Handler name for logging |
chain | number | yes | Chain ID to process |
interval | number | no | Process every Nth block (default: 1) |
startBlock | number | no | Inclusive start block |
endBlock | number | no | Inclusive end block |
onBlock self-registers — no config.yaml entry neededblock object provides number and timestamp (more fields may be added)Full reference: https://docs.envio.dev/docs/HyperIndex-LLM/hyperindex-complete