indexer-transactions

Select transaction and block fields for HyperIndex event handlers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

HyperIndex has no onTransaction handler, so developers often struggle to access transaction and block data inside event handlers and hit type errors when reading fields they never selected. This Skill explains how event.transaction and event.block work and how the fields option controls exactly what data they carry.

Core Features & Use Cases

  • Per-handler field selection: Declare transaction and block fields inline in indexer.onEvent or indexer.contractRegister so only requested data is fetched and typed.
  • Type-safe access: Reading a field not listed in fields produces a compile-time type error, while event.block.number is always available without listing.
  • Config-level fallback: Use field_selection in config.yaml to apply selections across all handlers of an event, with handler-level fields taking precedence.
  • Use Case: When indexing ERC-20 Transfer events, list fields: { transaction: ["hash", "from"], block: ["timestamp"] } to record who sent each transfer and when, without fetching unused data.

Quick Start

Ask the AI to add a fields option selecting transaction hash and block timestamp to your HyperIndex Transfer event handler.

Frequently Asked Questions about indexer-transactions

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

FAQPage Schema
How do I get transaction data in a HyperIndex event handler?

Access transaction data through event.transaction inside your handler, listing the fields you need in the fields option of indexer.onEvent. There is no onTransaction handler; transaction data only arrives through event handlers.

How to select block timestamp in an Envio indexer handler?

Add block: ["timestamp"] to the fields option of your indexer.onEvent call, then read event.block.timestamp in the handler. Only event.block.number is available without being listed.

Why does event.transaction.gasUsed give a type error in HyperIndex?

The type error occurs because gasUsed was not listed in the handler's fields option. HyperIndex types event.transaction and event.block based on your selection, so reading an unlisted field fails at compile time.

What is the difference between fields and field_selection in HyperIndex?

The fields option is declared per handler in indexer.onEvent and sits next to the code that reads the data. field_selection in config.yaml applies to every handler of an event or all events at root level, and a handler's fields overrides it.

Can two handlers on the same event select different fields?

Yes, two handlers registered on the same event can list different fields in their respective fields options. Each handler receives only the transaction and block fields it requested.

Which transaction fields are chain-specific in HyperIndex?

The l1Fee, l1GasPrice, l1GasUsed, l1FeeScalar, and gasUsedForL1 fields only apply to L2 chains, and root only appears on pre-Byzantium transactions. These fields read as undefined on chains where they do not apply.