com um clique
indexer-multichain
// Use when deploying an indexer across multiple chains. Entity ID namespacing to avoid collisions, chain-specific configuration patterns, and the context.chain runtime API.
// Use when deploying an indexer across multiple chains. Entity ID namespacing to avoid collisions, chain-specific configuration patterns, and the context.chain runtime API.
Use when something is unclear, confusing, or not covered by other skills. Search and read the latest Envio documentation without leaving the terminal.
Use when processing every block (or every Nth block) for time-series data, periodic snapshots, or block-level aggregations. indexer.onBlock API, where filter with block-number range and stride, 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. The `where` option supports static filters, dynamic per-chain functions, contract address filtering, and conditional enable/disable.
| name | indexer-multichain |
| description | Use when deploying an indexer across multiple chains. Entity ID namespacing to avoid collisions, chain-specific configuration patterns, and the context.chain runtime API. |
| metadata | {"managed-by":"envio"} |
Always prefix entity IDs with chainId to avoid collisions across chains:
const id = `${event.chainId}-${event.params.tokenId}`;
context.Token.set({ id, ...tokenData });
Never hardcode chainId = 1 — always use event.chainId.
Chain-specific singleton IDs (e.g., Bundle): ${event.chainId}-1
Contract.Event.handler(async ({ event, context }) => {
const chainId = context.chain.id;
const config = {
1: { wrappedNative: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" },
137: { wrappedNative: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270" },
}[chainId];
// context.chain.isRealtime is true once ALL chains have caught up to head
if (context.chain.isRealtime) {
// Realtime-only logic
}
});
Global contract definitions + chain-specific addresses:
contracts:
- name: ERC20
events:
- event: Transfer(indexed address from, indexed address to, uint256 value)
chains:
- id: 1
contracts:
- name: ERC20
address:
- 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
- id: 137
contracts:
- name: ERC20
address:
- 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
If something is unclear, use the
envio-docsskill to search and read the latest documentation.