indexer-multichain

Configures multichain blockchain indexers with per-chain data modes and entity ID namespacing.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Deploying a blockchain indexer across multiple chains introduces entity ID collisions, ambiguous data scoping, and chain-specific configuration complexity that can silently corrupt indexed data.

Core Features & Use Cases

  • Per-Chain Data Mode: Enable disable_default_cross_chain to give entities composite (id, chainId) primary keys, with per-chain effect caches, history, and reorg rollback.
  • Entity ID Namespacing: Prefix entity IDs with event.chainId to prevent collisions when rows are shared across chains, and mark shared entities with the @crossChain directive.
  • Chain-Specific Logic: Use the context.chain runtime API (context.chain.id, context.chain.isRealtime) plus YAML config with global contract definitions and per-chain addresses.
  • Use Case: Index USDC Transfer events on both Ethereum mainnet and Polygon with chain-specific contract addresses, keeping each chain's token balances as independent rows.

Quick Start

Set up my Envio indexer to track ERC20 Transfer events on Ethereum and Polygon with per-chain entity storage and chain-specific contract addresses.

Frequently Asked Questions about indexer-multichain

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

FAQPage Schema
How do I index the same contract on multiple chains with Envio?

Define the contract and its events once globally in the YAML config, then list each chain under `chains` with its own `id` and chain-specific contract addresses. Handlers run per chain, and `event.chainId` identifies the source chain.

How do I prevent entity ID collisions across chains in a multichain indexer?

Either prefix entity IDs with the chain ID, such as `${event.chainId}-${event.params.tokenId}`, or enable `disable_default_cross_chain: true` so entities get a composite `(id, chainId)` primary key automatically.

What does disable_default_cross_chain do in HyperIndex?

It switches entity storage to per-chain mode with composite `(id, chainId)` primary keys, per-chain effect caches, and chain-scoped history and reorg rollback. Handler code stays unchanged since each handler always runs on one chain.

When should I use the @crossChain directive on an entity?

Use `@crossChain` when `disable_default_cross_chain` is enabled but a specific entity should remain shared across all chains, such as a global counter. The directive is rejected by codegen if the flag is not set.

How do I run logic only when all chains have caught up to the chain head?

Check `context.chain.isRealtime` inside your handler; it becomes true once every configured chain has reached the head. Gate realtime-only logic, such as notifications, behind this flag.