# Envio docs: HyperIndex migration guides > Upgrade a V2 indexer to V3, or migrate from The Graph, Ponder or Alchemy, by hand or with AI. Generated at build time from the pages of https://docs.envio.dev. Each page below is the full markdown of one docs page, after a `` line. Append `.md` to that URL to fetch the page on its own. The index of every page is https://docs.envio.dev/llms.txt. Context files, one per product area: - [llms-hyperindex.txt](https://docs.envio.dev/llms-hyperindex.txt): HyperIndex core, about 47k tokens. Build, run and test an indexer: getting started, config.yaml, schema, handlers, CLI, testing, troubleshooting. - [llms-hyperindex-advanced.txt](https://docs.envio.dev/llms-hyperindex-advanced.txt): HyperIndex advanced features, about 32k tokens. Factories, the Effect API, wildcard indexing, preload, contract state, IPFS, HyperSync and RPC sources, reorgs, WebSockets. - [llms-hyperindex-reference.txt](https://docs.envio.dev/llms-hyperindex-reference.txt): HyperIndex performance and reference, about 27k tokens. Config schema reference, observability, performance tuning, benchmarks, supported chains and licensing. - [llms-hyperindex-examples.txt](https://docs.envio.dev/llms-hyperindex-examples.txt): HyperIndex examples and tutorials, about 16k tokens. Example indexers (Uniswap v4, Sablier, Velodrome and Aerodrome) and EVM tutorials. - llms-hyperindex-migration.txt (this file): HyperIndex migration guides, about 14k tokens. Upgrade a V2 indexer to V3, or migrate from The Graph, Ponder or Alchemy, by hand or with AI. - [llms-hyperindex-solana-fuel.txt](https://docs.envio.dev/llms-hyperindex-solana-fuel.txt): HyperIndex on Solana and Fuel, about 21k tokens. Solana programs (instruction and slot handlers, decoding, config) and Fuel contracts. - [llms-envio-cloud.txt](https://docs.envio.dev/llms-envio-cloud.txt): Envio Cloud, about 24k tokens. Deploy, monitor and manage hosted indexers: features, CLI, billing, organisations, self-hosting. - [llms-hypersync.txt](https://docs.envio.dev/llms-hypersync.txt): HyperSync core, about 36k tokens. EVM data: quickstart, API tokens, clients, query reference, curl, stream tuning, supported networks, tutorials. - [llms-hypersync-solana-fuel.txt](https://docs.envio.dev/llms-hypersync-solana-fuel.txt): HyperSync for Solana and Fuel, about 15k tokens. Solana HyperSync (query schema, client, curl examples) and HyperFuel, HyperSync for the Fuel network. - [llms-hyperrpc.txt](https://docs.envio.dev/llms-hyperrpc.txt): HyperRPC, about 6k tokens. Read-only JSON-RPC endpoint powered by HyperSync: supported methods, usage and supported networks. Pages in this file: - Migrate to HyperIndex V3 - How to Migrate Using AI - Migrate from The Graph to Envio - Migrate from Ponder to Envio - Migrate from Alchemy to Envio --- # Migrate to HyperIndex V3 > What's new in HyperIndex V3 and step-by-step instructions for upgrading an existing V2 project, from the unified handlers API and ESM to testing, ClickHouse storage and Solana. This guide covers what's new in V3 and every change required to upgrade a HyperIndex V2 project. New projects created with `pnpx envio init` are already on V3. For every release since 3.0, see the [Changelog](https://envio.dev/changelog). Easiest path - prompt your AI tool (Claude/Cursor/Codex): ``` Upgrade my indexer to V3 by following the migration instructions step by step https://docs.envio.dev/docs/HyperIndex/migrate-to-v3 ``` [Video: Migrate to HyperIndex V3](https://www.youtube.com/watch?v=Tv6oY2e1Fjs) ## What's New in V3 HyperIndex V3 is the current major version of HyperIndex, released in May 2026. It rebuilt the parts of HyperIndex that V2 had outgrown, from the handler API and module system to testing, storage and packaging. ### V2 vs V3 at a Glance | | V2 | V3 | Read more | | --- | --- | --- | --- | | Handler API | Generated exports for each contract and event | One `indexer` API for events, dynamic contracts and blocks | [Event handlers](https://docs.envio.dev/docs/HyperIndex/event-handlers) | | Event filtering | `eventFilters` on indexed parameters | `where`, which also handles per-chain filters, conditional handlers and per-event start blocks | [Wildcard indexing](https://docs.envio.dev/docs/HyperIndex/wildcard-indexing) | | Module system | CommonJS | ESM, so handler files can use top-level `await` | [Top-level await](https://docs.envio.dev/docs/HyperIndex/event-handlers#top-level-await) | | Handler files | A path for every contract in `config.yaml` | Picked up automatically from `src/handlers` | [Handler file path](https://docs.envio.dev/docs/HyperIndex/configuration-file#handler-file-path) | | Loading entities | Opt-in loaders or `preload_handlers` | Preload optimization, always on | [Preload optimization](https://docs.envio.dev/docs/HyperIndex/preload-optimization) | | Multichain ordering | Ordered or unordered | Unordered only | [Multichain indexing](https://docs.envio.dev/docs/HyperIndex/multichain-indexing) | | Testing | Mocha and Chai with manual mocks | `createTestIndexer()` with Vitest and snapshot tests | [Testing](https://docs.envio.dev/docs/HyperIndex/testing) | | Storage | Postgres | Postgres, plus ClickHouse chosen per entity | [Storage backends](https://docs.envio.dev/docs/HyperIndex/schema#choosing-a-storage-backend-storage) | | Metrics | Unofficial Prometheus metrics and `--bench` | Documented Prometheus metrics on `/metrics`, plus `envio metrics` | [Observability](https://docs.envio.dev/docs/HyperIndex/observability) | | Package manager | pnpm required | npm, pnpm, yarn or Bun | [CLI commands](https://docs.envio.dev/docs/HyperIndex/cli-commands) | | Solana | Not supported | Supported | [Solana](https://docs.envio.dev/docs/HyperIndex/solana) | ### What Else Came with 3.0 - **3x faster historical backfill**, from fetching several block ranges at once. - **A smaller `envio` package.** It went from 141MB to 53MB once the generated ReScript code was removed, and `envio codegen` is now near instant. - **An RPC for realtime only.** Set `for: realtime` on an RPC and it takes over once the indexer reaches the head. See [RPC sync](https://docs.envio.dev/docs/HyperIndex/rpc-sync). - **Config and live state in handlers.** The `indexer` value exposes chains, contracts, addresses and whether each chain is realtime. See [Accessing `config.yaml` data](https://docs.envio.dev/docs/HyperIndex/event-handlers#accessing-configyaml-data-in-handlers). - **Built for AI agents.** New projects ship with Claude and Cursor skills. See [Quickstart with AI](https://docs.envio.dev/docs/HyperIndex/quickstart-with-ai). For the full list, see the [v3.0.0 release notes](https://github.com/enviodev/hyperindex/releases/tag/v3.0.0). Every release since is on the [Changelog](https://envio.dev/changelog). [Video: HyperIndex V3 vs V2](https://www.youtube.com/watch?v=UgyO-G5pDtg) ## Step 0: Prepare on V2 (Recommended) While still on V2: 1. Upgrade to `envio@^2.32.6`. 2. Set `preload_handlers: true` in `config.yaml`. 3. If using loaders, migrate them per [Migrating from Loaders](https://docs.envio.dev/docs/HyperIndex/preload-optimization#migrating-from-loaders). 4. Verify with `pnpm dev`. ## Step 1: Update Node.js Use Node.js **22.15.0 or newer** (24 recommended). Earlier versions are unsupported. ## Step 2: Update `package.json` - Add `"type": "module"` (required - without it the project fails to start with ESM errors). - Set `engines.node` to `>=22.15.0`. - Update `envio` to the latest v3 release. - Remove `optionalDependencies.generated` - the local `generated` package no longer exists. ```json { "type": "module", "engines": { "node": ">=22.15.0" }, "dependencies": { "envio": "3.14.0" }, "devDependencies": { "@types/node": "24.12.2", "typescript": "6.0.3", "vitest": "4.1.0" } } ``` If you used `ts-node` for the start script, replace it with `"start": "envio start"`. ### Test runner **Option A - Vitest (recommended).** ```bash pnpm remove ts-mocha ts-node mocha chai @types/mocha @types/chai pnpm add -D vitest@4.1.0 ``` Set `"test": "vitest run"`, then move `test/Test.ts` → `src/indexer.test.ts` and update imports: ```typescript // Before (mocha/chai) import { describe, it } from "mocha"; import { expect } from "chai"; // After (vitest) import { describe, it, expect } from "vitest"; import { createTestIndexer } from "envio"; ``` **Option B - Keep Mocha.** Replace `ts-mocha`/`ts-node` with `tsx`: ```bash pnpm remove ts-mocha ts-node pnpm add -D tsx@4.21.0 ``` ```json { "scripts": { "mocha": "tsc --noEmit && NODE_OPTIONS='--no-warnings --import tsx' mocha --exit test/**/*.ts" } } ``` ## Step 3: Update `tsconfig.json` Update for ESM (copy-paste the file as-is, comments included): ```json { /* For details: https://www.totaltypescript.com/tsconfig-cheat-sheet */ "compilerOptions": { /* Base Options: */ "esModuleInterop": true, "skipLibCheck": true, "target": "es2022", "allowJs": true, "resolveJsonModule": true, "moduleDetection": "force", "isolatedModules": true, "verbatimModuleSyntax": true, /* Strictness */ "strict": true, "noUncheckedIndexedAccess": true, "noImplicitOverride": true, /* For running Envio: */ "module": "ESNext", "moduleResolution": "bundler", "noEmit": true, /* Code doesn't run in the DOM: */ "lib": ["es2022"], "types": ["node"] } } ``` :::tip `verbatimModuleSyntax` and `noUncheckedIndexedAccess` are optional extra strictness - disable them to simplify migration. ::: ## Step 4: Update `config.yaml` **Renames:** - `networks` → `chains` - `confirmed_block_threshold` → `max_reorg_depth` - `rpc_config` → `rpc` (now supports multiple URLs, `for: sync | realtime | fallback`, and WebSocket config) **Remove if present:** - `unordered_multichain_mode` and any `multichain: ordered` - unordered is the only mode in V3. - `loaders`, `preload_handlers` - Preload Optimization is always enabled. - `preRegisterDynamicContracts` - no longer needed. - `event_decoder` - the Rust decoder is the only implementation. - `output` - types always emitted to `.envio/`. **Env var → config:** replace the `MAX_BATCH_SIZE` env var with `full_batch_size: 5000`. **Optional (recommended):** move handler files to `src/handlers/` and drop the explicit `handler` paths (the `handler` field still works). ## Step 5: Update Environment Variables **Add** - if using HyperSync (the default), set `ENVIO_API_TOKEN` (get a free token at [envio.dev/app/api-tokens](https://envio.dev/app/api-tokens)). **Remove:** - `UNSTABLE__TEMP_UNORDERED_HEAD_MODE` - `UNORDERED_MULTICHAIN_MODE` - `MAX_BATCH_SIZE` (use `full_batch_size` in `config.yaml`) - `ENVIO_INDEXING_BLOCK_LAG` (use per-chain `block_lag`) **Rename:** - `TUI_OFF=true` → `ENVIO_TUI=false` (TUI also auto-disabled in CI and under AI agents) - `ENVIO_PG_PUBLIC_SCHEMA` → `ENVIO_PG_SCHEMA` (old name supported until v4) ## Step 6: Update Handler Code Contract-specific exports are removed. Register handlers through the unified `indexer` from the `envio` package, which replaces `generated`. ### Event handlers ```typescript // Before import { ERC20 } from "generated"; ERC20.Transfer.handler( async ({ event, context }) => {}, { wildcard: true, eventFilters: ({ chainId }) => [ { from: ZERO_ADDRESS, to: WHITELIST[chainId] }, ], } ); // After import { indexer } from "envio"; indexer.onEvent( { contract: "ERC20", event: "Transfer", wildcard: true, where: ({ chain }) => ({ params: [{ from: ZERO_ADDRESS, to: WHITELIST[chain.id] }], }), }, async ({ event, context }) => {}, ); ``` - `eventFilters` → `where`. Callback receives `{ chain }` (not `{ chainId }`) and returns `false`, `true`, or `{ params: [...], block?: { number: { _gte } } }`. Event filters accept only `_gte` on `block.number`; `_lte` and `_every` are for `indexer.onBlock`. - The top-level array shorthand is gone - wrap it in `{ params: [...] }`. **Filtering by the contract's own addresses** - V2's `eventFilters` `addresses` argument becomes `chain..addresses` (kept in sync with `context.chain..add(...)`): ```typescript // Before import { Safe } from "generated"; Safe.Transfer.handler(async ({ event, context }) => {}, { wildcard: true, eventFilters: ({ addresses }) => [{ from: addresses }, { to: addresses }], }); // After import { indexer } from "envio"; indexer.onEvent( { contract: "Safe", event: "Transfer", wildcard: true, where: ({ chain }) => ({ params: [{ from: chain.Safe.addresses }, { to: chain.Safe.addresses }], }), }, async ({ event, context }) => {}, ); ``` ### Dynamic contract registration ```typescript // Before import { UniV3 } from "generated"; UniV3.PoolFactory.contractRegister(async ({ event, context }) => { context.addPool(event.params.poolAddress); }); // After import { indexer } from "envio"; indexer.contractRegister( { contract: "UniV3", event: "PoolFactory" }, async ({ event, context }) => { context.chain.Pool.add(event.params.poolAddress); }, ); ``` `context.add(addr)` → `context.chain..add(addr)`. ### Block handlers **Behavior change.** V2's `onBlock` ran on one chain (its `chain` option) with top-level `interval`/`startBlock`/`endBlock`. V3's `indexer.onBlock` runs on **every chain by default**. To restore V2's single-chain + range + interval behavior, pass a `where` callback that returns `false` for unwanted chains and `{ block: { number: { _gte, _lte, _every } } }` for the range/interval. ```typescript // Before — only chain 1, every 100 blocks, fixed range import { onBlock } from "generated"; onBlock( { name: "Ranges", chain: 1, startBlock: 20_000_000, endBlock: 22_000_000, interval: 100 }, async ({ block, context }) => {}, ); // After import { indexer } from "envio"; indexer.onBlock( { name: "Ranges", where: ({ chain }) => { if (chain.id !== 1) return false; return { block: { number: { _gte: 20_000_000, _lte: 22_000_000, _every: 100 } } }; }, }, async ({ block, context }) => {}, ); ``` To run on **every** chain (the new default), omit `where`. Inside the handler, `block.chainId` → `context.chain.id`. ### `getWhere` API Switch to GraphQL-style filter syntax (new operators: `_gte`, `_lte`, `_in`): ```typescript // Before await context.Transfer.getWhere.from.eq("0x123..."); await context.Transfer.getWhere.value.gt(1000n); // After await context.Transfer.getWhere({ from: { _eq: "0x123..." } }); await context.Transfer.getWhere({ value: { _gt: 1000n } }); ``` ### Rename and removal cheat sheet | V2 (removed) | V3 | | --- | --- | | `Contract.Event.handler(...)` | `indexer.onEvent({ contract, event, ...options }, handler)` | | `Contract.Event.contractRegister(...)` | `indexer.contractRegister({ contract, event }, handler)` | | `onBlock({ chain, ... }, handler)` | `indexer.onBlock({ name, where? }, handler)` | | `context.add(addr)` | `context.chain..add(addr)` | | `eventFilters` option | `where` callback returning `{ params: [...] }` | | `experimental_createEffect` | `createEffect` | | `block.chainId` (in block handlers) | `context.chain.id` | | `transaction.kind` | `transaction.type` | | `transaction.chainId` | `context.chain.id` or `event.chainId` | | `chain` type | `ChainId` (now a union type) | | `getGeneratedByChainId(...)` | `indexer.chains[chainId]` | | `Entity.getWhere.field.eq(value)` | `Entity.getWhere({ field: { _eq: value } })` | | `Entity.getWhere.field.gt(value)` | `Entity.getWhere({ field: { _gt: value } })` | | `Entity.getWhere.field.lt(value)` | `Entity.getWhere({ field: { _lt: value } })` | | Lowercased entity types (e.g. `transfer`) | Capitalized (`Transfer`) | | `ERC20_Transfer_eventLog` | `EvmEvent<"ERC20", "Transfer">` | | `ERC20_Transfer_block` | `EvmEvent<"ERC20", "Transfer">["block"]` | | `MyEnum` (direct export) | `Enum<"MyEnum">` | | `MyEntity` (direct export) | `Entity<"MyEntity">` (preferred; direct still exported) | Other type changes: `Address` is now `` `0x${string}` `` (was `string`); entity array fields are `readonly`; `S.nullable` returns `T | null` (was `T | undefined`); the internal `ContractType` enum was removed. ## Step 7: Remove `generated` The `generated` package is no longer needed - remove it. Import everything from `"envio"` instead. This works via `envio-env.d.ts`, which is linked automatically (no `tsconfig.json` change needed). ## Step 8: Update Tests `MockDb` is removed. Use `createTestIndexer()` with `simulate`. ```diff -import { TestHelpers, type User } from "generated"; -const { MockDb, Greeter, Addresses } = TestHelpers; +import { createTestIndexer, type User, TestHelpers } from "envio"; +const { Addresses } = TestHelpers; it("A NewGreeting event creates a User entity", async (t) => { - const mockDbInitial = MockDb.createMockDb(); + const indexer = createTestIndexer(); const userAddress = Addresses.defaultAddress; const greeting = "Hi there"; - const mockNewGreetingEvent = Greeter.NewGreeting.createMockEvent({ - greeting: greeting, - user: userAddress, - }); - - const updatedMockDb = await Greeter.NewGreeting.processEvent({ - event: mockNewGreetingEvent, - mockDb: mockDbInitial, - }); + await indexer.process({ + chains: { + 137: { + simulate: [ + { contract: "Greeter", event: "NewGreeting", params: { greeting, user: userAddress } }, + ], + }, + }, + }); const expectedUserEntity: User = { id: userAddress, latestGreeting: greeting, numberOfGreetings: 1, greetings: [greeting], }; - const actualUserEntity = updatedMockDb.entities.User.get(userAddress); + const actualUserEntity = await indexer.User.getOrThrow(userAddress); t.expect(actualUserEntity).toEqual(expectedUserEntity); }); ``` | Old (`MockDb`) | New (`createTestIndexer`) | | --- | --- | | `MockDb.createMockDb()` | `createTestIndexer()` | | `Contract.Event.createMockEvent({...})` | Inline in `simulate: [{ contract, event, params }]` | | `Contract.Event.processEvent({event,mockDb})` | `indexer.process({ chains: { id: { simulate } } })` | | `mockDb.entities.Entity.get(id)` | `await indexer.Entity.getOrThrow(id)` | | `mockDb.entities.Entity.set({...})` | `indexer.Entity.set({...})` | | Manual handler threading & event chaining | Automatic - pass multiple events in `simulate` | ## Step 9: Update CLI Usage - `envio dev` no longer auto-resets the DB - use `envio dev -r` (`--restart`) if you relied on that. - `envio start` is now production-only; use `envio dev` for local development. - Handler file changes no longer trigger codegen on `pnpm dev`. ## Step 10: Run Codegen and Verify ```bash pnpm envio codegen pnpm dev ``` Postgres column type changes (`raw_events.event_id`: `NUMERIC`→`BIGINT`, `raw_events.serial`: `SERIAL`→`BIGSERIAL`, `envio_chains.events_processed`: `INTEGER`→`BIGINT`, `envio_checkpoints.id`: `INTEGER`→`BIGINT`) apply automatically. The deprecated `envio_chains._num_batches_fetched` always returns `0`. ## Step 11: Update Agent Skills Refresh the bundled agent skills so agent-driven development stays aligned with V3: ```bash pnpx envio skills update ``` This populates `.claude/skills` (consumed by Claude, Cursor, and other agentic tooling). Re-run it on each new HyperIndex release. ## Getting Help Issues during migration? Join our [Discord community](https://discord.gg/envio). --- # How to Migrate Using AI > Use an AI programming assistant like Cursor or Claude Code with HyperIndex Claude skills to migrate your existing indexer, such as a subgraph or Ponder project, to Envio HyperIndex. HyperIndex includes built-in Claude skills that show AI programming assistants how to write HyperIndex config, schema, handlers, and tests. Give your assistant the prompt below and it scaffolds a HyperIndex indexer from your existing indexer, matches the config, and ports your logic. This is the recommended way to migrate complex indexers. ## Step 1: Create an Envio API Token Create an API token at [envio.dev/app/api-tokens](https://envio.dev/app/api-tokens) and set it in the shell you start your AI programming assistant from (or in your shell profile): ```bash export ENVIO_API_TOKEN= ``` `envio init` reads the token from this environment variable and saves it in your new indexer's `.env`, so you never need to paste it into the prompt. If you skip this step, your assistant asks you to add the token to the new indexer's `.env` after scaffolding it. See [About Envio API Token](https://docs.envio.dev/docs/HyperIndex/quickstart-with-ai.md#about-envio-api-token) for details. ## Step 2: Run Your AI Programming Assistant Open your AI programming assistant (for example Claude Code or Cursor) in a new, empty directory. **Put your assistant in plan mode first**, then paste the following prompt. Replace `` with the local path or git URL of the indexer you want to migrate: ```xml Migrate my existing indexer at (a local path or git URL) to Envio HyperIndex. The existing indexer is the source of truth. Create the HyperIndex indexer in `hyperindex-indexer/` (migration target). Follow these phases in order: Phase 0: Scaffold the boilerplate - If is a git URL, clone it into `existing-indexer/`. - Pick one contract on one chain from the existing indexer's config (for example `subgraph.yaml` or `ponder.config.ts`) and scaffold it non-interactively: npx envio init -d hyperindex-indexer --package-manager npm \ contract-import -c \ local -a --contract-name \ -b --single-contract --all-events If the ABI is not in a JSON file, save it as one first. If HyperSync doesn't support the chain, also pass `-r -s `. `envio init` reads `ENVIO_API_TOKEN` from the environment, so don't pass my token in `--api-token`. If it fails because no token is set, rerun it with `--api-token ""`, and once the boilerplate is set up, ask me to add my token to `ENVIO_API_TOKEN` in `hyperindex-indexer/.env`. - Update `hyperindex-indexer/config.yaml` to match the existing indexer: every contract, chain, address, start block, and event. Contracts created at runtime (subgraph `templates`, Ponder factories) become contracts without an `address`. - Run `npx envio codegen` in `hyperindex-indexer/` and fix any errors. Phase 1: Plan - Read every `SKILL.md` under `hyperindex-indexer/.claude/skills/`. They describe HyperIndex config, schema, handlers and tests. - Produce a migration plan mapping each component of the existing indexer to its HyperIndex equivalent. - Flag anything that has no direct equivalent and propose a workaround. - Do NOT write handler code yet. Phase 2: Implement - Migrate the entire indexer following the plan and skill guides. - Process one handler file at a time. - After each file, run `npx envio codegen` and `npx tsc --noEmit` in `hyperindex-indexer/` to validate, and verify it against the migration plan before moving on. Phase 3: Verify - Walk through every item in the migration plan and confirm it is implemented. - Run `npx tsc --noEmit` and `npm test` in `hyperindex-indexer/` and fix any errors. - List any items you could not complete and why. - Only create or modify files in `hyperindex-indexer/`. Do not change the existing indexer. - Preserve all contracts, chains, entity fields, and event mappings from the existing indexer. - Do not skip or summarize plan items. Execute every one. - If you are uncertain about a migration decision, pause and ask me. ``` :::tip - After migration, run `npm run dev` in `hyperindex-indexer/` to verify the indexer runs correctly - If you migrated a subgraph, use the [Indexer Migration Validator](https://github.com/enviodev/indexer-migration-validator) to compare outputs between your subgraph and the new HyperIndex indexer ::: ## Manual Migration For step by step manual guides, see [Migrate from The Graph](https://docs.envio.dev/docs/HyperIndex/migration-guide.md) and [Migrate from Ponder](https://docs.envio.dev/docs/HyperIndex/migrate-from-ponder.md). --- # Migrate from The Graph to Envio > Easily migrate your existing subgraph to HyperIndex for faster indexing, multichain support, and a better developer experience. :::info Please reach out to our team on [Discord](https://discord.gg/envio) for personalized migration assistance. ::: :::tip Already on HyperIndex V2? This page covers migrating from The Graph to Envio, with all examples shown in current HyperIndex V3 syntax (`indexer.onEvent(...)`, `chains:`). If instead you are upgrading an existing HyperIndex project from V2 to V3, follow the [Migrate to V3](https://docs.envio.dev/docs/HyperIndex/migrate-to-v3.md) guide. ::: ## Introduction Migrating your existing subgraph to Envio's HyperIndex is designed to be a developer-friendly process. HyperIndex draws strong inspiration from The Graph’s subgraph architecture, which makes the migration simple, especially with the help of coding assistants like Cursor and AI tools (give your assistant our [HyperIndex context file](https://docs.envio.dev/llms-hyperindex.txt) or connect it to the [docs MCP server](https://docs.envio.dev/docs/HyperIndex/mcp-server)). The process is simple but requires a good understanding of the underlying concepts. If you are new to HyperIndex, we recommend starting with the [Quickstart](https://docs.envio.dev/docs/HyperIndex/quickstart) guide. :::tip Prefer AI-assisted migration? If you want an assistant-led workflow, see [How to Migrate Using AI](https://docs.envio.dev/docs/HyperIndex/migrate-with-ai.md) for a guided process that works in both Cursor and Claude Code. ::: ## Run your subgraph as it is (preview) The Envio Subgraph Engine runs an unmodified subgraph project on HyperIndex. Point it at a folder with a `subgraph.yaml` and it runs on HyperIndex underneath, reading the manifest, schema and mappings you already have. ```bash cd my-subgraph && pnpx envio@subgraph dev ``` This is a preview, published under the `subgraph` npm tag rather than in the main release, so use `envio@subgraph` as shown above to get the latest preview build. **No changes to your subgraph are needed.** The `subgraph.yaml`, schema, mappings and ABIs stay exactly as they are. The engine runs `graph codegen` for you when the `generated` folder is missing. ### Contract calls need an RPC HyperSync and HyperRPC serve logs and blocks rather than `eth_call`, so a subgraph that calls contracts needs an RPC endpoint in the environment: ```bash ENVIO_SUBGRAPH_RPC=https://... ``` Without it, the engine refuses to start and names the binding it found, such as `Gravity.bind(...)`. Each call is made at the block of the event that triggered it, so indexing history needs an RPC that serves archive state. ### What it does not run yet Anything the engine does not support is refused when the config is parsed, naming the feature and where it was found, rather than failing part way through indexing. Call handlers and grafting are refused this way today. ### When to migrate properly instead Converting your subgraph to HyperIndex gives you multichain indexing, TypeScript handlers and the rest of the features in this guide. Use the sections below for that, or [How to Migrate Using AI](https://docs.envio.dev/docs/HyperIndex/migrate-with-ai.md) for an assistant-led conversion. ## Why Migrate to HyperIndex? - **Superior Performance**: faster indexing than subgraphs, measured in our [open benchmark](https://github.com/enviodev/open-indexer-benchmark) - **Lower Costs**: Reduced infrastructure requirements and operational expenses - **Better Developer Experience**: Simplified configuration and deployment - **Advanced Features**: Access to capabilities not available in other indexing solutions - **Seamless Integration**: Easy integration with existing GraphQL APIs and applications If you are still deciding, our [comparison of the best blockchain indexers in 2026](https://docs.envio.dev/blog/best-blockchain-indexers-2026) covers HyperIndex against The Graph, Goldsky, SubQuery, Subsquid, Ormi, and Ponder with side-by-side benchmarks. ## Subgraph to HyperIndex Migration Overview Migration consists of three major steps: 1. Subgraph.yaml migration 1. Schema migration - near copy paste 1. Event handler migration At any point in the migration run `pnpm envio codegen` to verify the `config.yaml` and `schema.graphql` files are valid. or run `pnpm dev` to verify the indexer is running and indexing correctly. ### 0.5 Use `pnpx envio init` to generate a boilerplate As a first step, we recommend using `pnpx envio init` to generate a boilerplate for your project. This will handle the creation of the `config.yaml` file and a basic `schema.graphql` file with generic handler functions. ### 1. `subgraph.yaml` → `config.yaml` `pnpx envio init` will generate this for you. It's a simple configuration file conversion. Effectively specifying which contracts to index, which chains to index (multiple chains can be specified with envio) and which events from those contracts to index. Take the following conversion as an example, where the `subgraph.yaml` file is converted to `config.yaml` the below comparisons is for the Uniswap v4 pool manager subgraph. The Graph - `subgraph.yaml` ```yaml specVersion: 0.0.4 description: Uniswap is a decentralized protocol for automated token exchange on Ethereum. repository: https://github.com/Uniswap/v4-subgraph schema: file: ./schema.graphql features: - nonFatalErrors - grafting dataSources: - kind: ethereum/contract name: PositionManager network: mainnet source: abi: PositionManager address: "0xbD216513d74C8cf14cf4747E6AaA6420FF64ee9e" startBlock: 21689089 mapping: kind: ethereum/events apiVersion: 0.0.7 language: wasm/assemblyscript file: ./src/mappings/index.ts entities: - Position abis: - name: PositionManager file: ./abis/PositionManager.json eventHandlers: - event: Subscription(indexed uint256,indexed address) handler: handleSubscription - event: Unsubscription(indexed uint256,indexed address) handler: handleUnsubscription - event: Transfer(indexed address,indexed address,indexed uint256) handler: handleTransfer ``` HyperIndex - `config.yaml` ```yaml # yaml-language-server: $schema=./node_modules/envio/evm.schema.json name: uni-v4-indexer chains: - id: 1 start_block: 21689089 contracts: - name: PositionManager address: "0xbD216513d74C8cf14cf4747E6AaA6420FF64ee9e" events: - event: Subscription(uint256 indexed tokenId, address indexed subscriber) - event: Unsubscription(uint256 indexed tokenId, address indexed subscriber) - event: Transfer(address indexed from, address indexed to, uint256 indexed id) ``` For any potential hurdles, please refer to the [Configuration File](https://docs.envio.dev/docs/HyperIndex/configuration-file.md) documentation. ## 2. Schema migration `copy` & `paste` the schema from the subgraph to the HyperIndex config file. Small nuance differences: - You can remove the `@entity` directive - [Enums](https://docs.envio.dev/docs/HyperIndex/schema.md#enum-types) - [BigDecimals](https://docs.envio.dev/docs/HyperIndex/schema.md#working-with-bigdecimal) - GraphQL `interface` types are not supported - `Int8` is not supported. Use `BigInt` - A list of entities, such as `tokens: [Token!]!`, needs `@derivedFrom`. The Graph lets you store such a list directly, but `envio codegen` rejects it. Store a `[String!]!` of ids instead, or derive the list from the other side ## 3. Event handler migration This consists of two parts 1. Converting assemblyscript to typescript 1. Converting the subgraph syntax to HyperIndex syntax ### 3.1 Converting Assemblyscript to Typescript The subgraph uses assemblyscript to write event handlers. The HyperIndex syntax is usually in typescript. Since assemblyscript is a subset of typescript, it's quite simple to copy and paste the code, especially so for pure functions. ### 3.2 Converting the subgraph syntax to HyperIndex syntax There are some subtle differences in the syntax of the subgraph and HyperIndex. Including but not limited to the following: - Replace Entity.save() with context.Entity.set() - Convert to async handler functions - Use `await` for loading entities `const x = await context.Entity.get(id)` - Use [dynamic contract registration](https://docs.envio.dev/docs/HyperIndex/dynamic-contracts.md) to register contracts The below code snippets can give you a basic idea of what this difference might look like. The Graph - `eventHandler.ts` ```typescript export function handleSubscription(event: SubscriptionEvent): void { const subscription = new Subscribe(event.transaction.hash + event.logIndex); subscription.tokenId = event.params.tokenId; subscription.address = event.params.subscriber.toHexString(); subscription.logIndex = event.logIndex; subscription.blockNumber = event.block.number; subscription.position = event.params.tokenId; subscription.save(); } ``` HyperIndex - `eventHandler.ts` ```typescript import { indexer } from "envio"; indexer.onEvent( { contract: "PositionManager", event: "Subscription", // event.transaction is empty unless you select its fields fields: { transaction: ["hash"] }, }, async ({ event, context }) => { const entity = { id: event.transaction.hash + event.logIndex, tokenId: event.params.tokenId, address: event.params.subscriber, blockNumber: event.block.number, logIndex: event.logIndex, position: event.params.tokenId, }; context.Subscription.set(entity); }, ); ``` ## Extra tips HyperIndex is a powerful tool that can be used to index any contract. There are some features that are especially powerful that go above subgraph implementations and so in some cases you may want to optimise your migration to HyperIndex further to take advantage of these features. Here are some useful tips: - Use the `fields` registration option (or `field_selection` in `config.yaml`) to opt into transaction and block fields (e.g. `hash`, `status`, `gasUsed`) that are not included by default, see [Transaction receipts](#transaction-receipts) for a migration-focused example and [Selecting Block and Transaction Fields](https://docs.envio.dev/docs/HyperIndex/event-handlers.md#selecting-block-and-transaction-fields) for the details. - Multichain indexing in V3 always runs in unordered mode, which is the most common need and provides better performance - see [Multichain Indexing](https://docs.envio.dev/docs/HyperIndex/multichain-indexing.md). (In V2 this required setting `unordered_multichain_mode: true`; in V3 there is no opt-in, and the V2 `multichain: ordered` mode has been removed.) - Use wildcard indexing to index by event signatures rather than by contract address. - HyperIndex uses the standard GraphQL query language, whereas TheGraph uses a custom GraphQL syntax. You can read about the differences and how to convert queries in our [Query Conversion Guide](https://docs.envio.dev/docs/HyperIndex/query-conversion). We also provide a query converter tool for backwards compatibility with existing TheGraph queries. - Preload Optimization is always on in V3 and speeds up historical sync by batching the entity reads in your handlers and running external calls in parallel. You can read more about it [here](https://docs.envio.dev/docs/HyperIndex/preload-optimization). - HyperIndex is very flexible and can be used to index offchain data too or send messages to a queue etc for fetching external data, you can further optimise the fetching by using the [effects api](https://docs.envio.dev/docs/HyperIndex/effect-api) ### Transaction receipts In The Graph, you opt into receipt data per-handler with `receipt: true` in `subgraph.yaml`: ```yaml eventHandlers: - event: Transfer(indexed address,indexed address,indexed uint256) handler: handleTransfer receipt: true ```` This makes `event.receipt` available inside the handler with fields like `status`, `gasUsed`, and `logs`. In HyperIndex, receipt-level fields are transaction fields. There is no separate receipt object - the fields are accessed directly on `event.transaction`. Since v3.7, request them with the registration's `fields` option: ```typescript import { indexer } from "envio"; indexer.onEvent( { contract: "MyContract", event: "Transfer", // status: 1 = success, 0 = reverted // contractAddress: set for contract-creation transactions fields: { transaction: ["hash", "status", "gasUsed", "cumulativeGasUsed", "contractAddress", "logsBloom"] }, }, async ({ event, context }) => { const { status, gasUsed } = event.transaction; // ... }, ); ``` `field_selection` in `config.yaml` still works and applies to every handler of the event: ```yaml field_selection: transaction_fields: - hash - status - gasUsed ``` See the full list of available `transaction_fields` in the [Configuration File](https://docs.envio.dev/docs/HyperIndex/configuration-file.md#field-selection) docs. ## Validating Your Migration After completing your migration, it's important to verify that your HyperIndex indexer produces the same data as your original subgraph. Use the [Indexer Migration Validator](https://github.com/enviodev/indexer-migration-validator) CLI tool to compare results between both endpoints and identify any discrepancies. The tool automatically generates entity configs from your GraphQL schema and provides detailed field-level analysis of differences. ## Share Your Learnings If you discover helpful tips during your migration, we'd love to hear them. Share them with us in [Discord](https://discord.gg/envio) and help future developers. ## Getting Help **Join Our Discord**: The fastest way to get personalized help is through our [Discord community](https://discord.gg/envio). --- # Migrate from Ponder to HyperIndex > Migrate a Ponder indexer to HyperIndex. Convert the config, schema and handlers, with a mapping of every common Ponder API. > **Need help?** Reach out on [Discord](https://discord.gg/envio) for personalized migration assistance. Migrating from Ponder to HyperIndex is straightforward - both frameworks use TypeScript, index EVM events, and expose a GraphQL API. The key differences are the config format, schema syntax, and entity operation API. If you are new to HyperIndex, start with the [Quickstart](https://docs.envio.dev/docs/HyperIndex/quickstart) guide first. If you are new to the category entirely, see [what a blockchain indexer is](https://docs.envio.dev/blog/what-is-a-blockchain-indexer) for the wider context. :::tip Prefer AI-assisted migration? For an assistant-led workflow, see [How to Migrate Using AI](https://docs.envio.dev/docs/HyperIndex/migrate-with-ai.md), which includes a shared process for Cursor and Claude Code. ::: ## Why Migrate to HyperIndex? - **Faster historical sync** via [HyperSync](https://docs.envio.dev/docs/HyperIndex/hypersync), measured in our [open benchmark](https://github.com/enviodev/open-indexer-benchmark) - **Multichain by default** - index any number of chains in one config - **Same language** - your TypeScript logic transfers directly ## Migration Overview Migration has three steps: 1. `ponder.config.ts` → `config.yaml` 2. `ponder.schema.ts` → `schema.graphql` 3. Event handlers - adapt syntax and entity operations At any point, run: ```bash pnpm envio codegen # validate config + schema, regenerate types pnpm dev # run the indexer locally ``` --- ## Step 0: Bootstrap the Project ```bash pnpx envio init ``` This generates a `config.yaml`, a starter `schema.graphql`, and handler stubs. Use your Ponder project as the source of truth for contract addresses, ABIs, and events, then fill in the generated files. --- ## Step 1: `ponder.config.ts` → `config.yaml` **Ponder** ```typescript import { createConfig } from "ponder"; export default createConfig({ chains: { mainnet: { id: 1, rpc: process.env.PONDER_RPC_URL_1 }, }, contracts: { MyToken: { abi: myTokenAbi, chain: "mainnet", address: "0xabc...", startBlock: 18000000, }, }, }); ``` **HyperIndex (v3)** ```yaml # yaml-language-server: $schema=./node_modules/envio/evm.schema.json name: my-indexer contracts: - name: MyToken abi_file_path: ./abis/MyToken.json events: - event: Transfer - event: Approval chains: - id: 1 start_block: 0 contracts: - name: MyToken address: - 0xabc... start_block: 18000000 ``` > **v2 note**: HyperIndex v2 uses `networks` instead of `chains`. See the [v2→v3 migration guide](https://docs.envio.dev/docs/HyperIndex/migrate-to-v3). Key differences: | Concept | Ponder | HyperIndex | | --- | --- | --- | | Config format | `ponder.config.ts` (TypeScript) | `config.yaml` (YAML) | | Chain reference | Named + viem object | Numeric chain ID | | RPC URL | In config | Optional `rpc` per chain in `config.yaml`; HyperSync needs none | | ABI source | TypeScript import | JSON file (`abi_file_path`) | | Events to index | Inferred from handlers | Explicit `events:` list | | Handler file | Inferred | Any file under `src/handlers/` (loaded automatically) | **Convert your ABI**: Ponder uses TypeScript ABI exports (`as const`). HyperIndex needs a plain JSON file in `abis/`. Strip the `export const ... =` wrapper and `as const` and save as `.json`. ### Field selection - accessing transaction and block fields By default, `event.block` has only `number`, `timestamp` and `hash`, and `event.transaction` is empty. Reading a field you haven't selected, like `event.transaction.hash`, is a type error. Since v3.7, select fields on the registration with the `fields` option: ```typescript indexer.onEvent( { contract: "MyToken", event: "Transfer", fields: { transaction: ["hash"] } }, async ({ event, context }) => { event.transaction.hash; // string }, ); ``` Or select them in `config.yaml` for every handler of an event: ```yaml events: - event: Transfer field_selection: transaction_fields: - hash ``` Or declare once at the top level to apply to all events: ```yaml name: my-indexer field_selection: transaction_fields: - hash contracts: # ... ``` See the full list of available fields in the [Configuration File](https://docs.envio.dev/docs/HyperIndex/config-schema-reference#fieldselection) docs. --- ## Step 2: `ponder.schema.ts` → `schema.graphql` **Ponder** ```typescript import { onchainTable, primaryKey, index } from "ponder"; export const token = onchainTable("token", (t) => ({ address: t.hex().primaryKey(), symbol: t.text().notNull(), balance: t.bigint().notNull(), })); export const transferEvent = onchainTable( "transfer_event", (t) => ({ id: t.text().primaryKey(), from: t.hex().notNull(), to: t.hex().notNull(), amount: t.bigint().notNull(), timestamp: t.integer().notNull(), }), (table) => ({ fromIdx: index().on(table.from), }), ); ``` **HyperIndex** ```graphql type Token { id: ID! symbol: String! balance: BigInt! } type TransferEvent { id: ID! from: String! @index to: String! amount: BigInt! timestamp: Int! } ``` Type mapping: | Ponder | HyperIndex GraphQL | | --- | --- | | `t.hex()` | `String!` | | `t.text()` | `String!` | | `t.bigint()` | `BigInt!` | | `t.integer()` | `Int!` | | `t.boolean()` | `Boolean!` | | `t.real()` / `t.doublePrecision()` | `Float!` | | `t.hex().array()` | `[String!]!` | **Primary keys**: HyperIndex requires a single `id` field on every entity, typed `ID!`, `String!`, `Int!`, or `BigInt!`. For composite PKs (e.g. `owner + spender`), construct the ID string manually: `` `${owner}_${spender}` ``. **Indexes**: Replace `index().on(column)` with an [`@index`](https://docs.envio.dev/docs/HyperIndex/schema) directive on the field. **Relations**: Replace Ponder's `relations()` call with [`@derivedFrom`](https://docs.envio.dev/docs/HyperIndex/schema) on the parent entity: ```graphql type Token { id: ID! transfers: [TransferEvent!]! @derivedFrom(field: "token") } type TransferEvent { id: ID! token: Token! } ``` `@derivedFrom(field:)` names the relationship field on the other entity, without the `_id` suffix. Codegen then exposes that field to your handlers as `token_id`. See the full [Schema](https://docs.envio.dev/docs/HyperIndex/schema) docs. ## Step 3: Event Handlers ### Handler registration **Ponder** ```typescript import { ponder } from "ponder:registry"; ponder.on("MyToken:Transfer", async ({ event, context }) => { // ... }); ``` **HyperIndex** ```typescript import { indexer } from "envio"; indexer.onEvent( { contract: "MyToken", event: "Transfer" }, async ({ event, context }) => { // ... }, ); ``` ### Event data access | Data | Ponder | HyperIndex | | --- | --- | --- | | Event parameters | `event.args.name` | `event.params.name` | | Contract address | `event.log.address` | `event.srcAddress` | | Chain ID | `context.chain.id` | `event.chainId` | | Block number | `event.block.number` | `event.block.number` | | Block timestamp | `event.block.timestamp` (bigint) | `event.block.timestamp` (number) | | Tx hash | `event.transaction.hash` | `event.transaction.hash` ⚠️ needs `fields` or `field_selection` | ### Entity operations | Intent | Ponder | HyperIndex | | --- | --- | --- | | Insert | `context.db.insert(t).values({...})` | `context.Entity.set({ id, ...fields })` | | Update | `context.db.update(t, pk).set({...})` | `get` → spread → `context.Entity.set({ ...existing, ...changes })` | | Upsert | `.insert().values().onConflictDoUpdate()` | `context.Entity.getOrCreate({ id, ...defaults })` → `set` | | Read (nullable) | `context.db.find(table, pk)` | `context.Entity.get(id)` | | Read (throws) | manual null check | `context.Entity.getOrThrow(id)` | **Full handler example** _Ponder_ ```typescript ponder.on("MyToken:Transfer", async ({ event, context }) => { await context.db.insert(transferEvent).values({ id: event.id, from: event.args.from, to: event.args.to, amount: event.args.amount, timestamp: Number(event.block.timestamp), }); await context.db .update(token, { address: event.args.to }) .set((row) => ({ balance: row.balance + event.args.amount })); }); ``` _HyperIndex_ ```typescript import { indexer } from "envio"; indexer.onEvent( { contract: "MyToken", event: "Transfer", fields: { transaction: ["hash"] } }, async ({ event, context }) => { context.TransferEvent.set({ id: `${event.transaction.hash}_${event.logIndex}`, from: event.params.from, to: event.params.to, amount: event.params.amount, timestamp: event.block.timestamp, }); const token = await context.Token.getOrThrow(event.params.to); context.Token.set({ ...token, balance: token.balance + event.params.amount, }); }, ); ``` > **Important**: Entity objects from `context.Entity.get()` are read-only. Always spread (`...existing`) and set new fields - never mutate directly. See the [Event Handlers](https://docs.envio.dev/docs/HyperIndex/event-handlers) docs for the full API reference. ## Extra Tips ### Factory contracts (dynamic registration) Replace Ponder's `factory()` helper in config with a [`contractRegister`](https://docs.envio.dev/docs/HyperIndex/dynamic-contracts) handler: ```typescript import { indexer } from "envio"; // Registers each newly deployed contract for indexing indexer.contractRegister( { contract: "MyFactory", event: "ContractCreated" }, async ({ event, context }) => { context.chain.MyContract.add(event.params.contractAddress); }, ); ``` In `config.yaml`, omit the `address` field for the dynamically registered contract. ### External calls Replace `context.client.readContract(...)` with the [Effect API](https://docs.envio.dev/docs/HyperIndex/effect-api) to safely isolate external calls from the sync path: ```typescript import { createEffect, S } from "envio"; export const getSymbol = createEffect( { name: "getSymbol", input: S.schema({ address: S.string, chainId: S.number }), output: S.string, rateLimit: false, // required: false or { calls, per } cache: true, }, async ({ input }) => { /* viem call here */ }, ); // In handler: const symbol = await context.effect(getSymbol, { address, chainId: event.chainId, }); ``` ### Multichain Add multiple entries under `chains:`. Set `disable_default_cross_chain: true` in `config.yaml` (what `envio init` templates do) to key each entity on `(id, chainId)`, so the same id on two chains is two rows. Without it, entities are shared across chains, so namespace your entity IDs by chain to prevent collisions: ```typescript const id = `${event.chainId}_${event.params.tokenId}`; ``` See [Multichain Indexing](https://docs.envio.dev/docs/HyperIndex/multichain-indexing) for configuration details. ### Wildcard indexing HyperIndex supports [wildcard indexing](https://docs.envio.dev/docs/HyperIndex/wildcard-indexing) - index events by signature across all contracts on a chain without specifying addresses. ## Validating Your Migration Use the [Indexer Migration Validator](https://github.com/enviodev/indexer-migration-validator) CLI to compare entity data between your Ponder and HyperIndex endpoints field-by-field. ## Getting Help - **Discord**: [discord.gg/envio](https://discord.gg/envio) - fastest way to get help - **Docs**: [the HyperIndex documentation](https://docs.envio.dev/docs/HyperIndex/overview) - **Docs for AI agents**: the [HyperIndex context file](https://docs.envio.dev/llms-hyperindex.txt) or the [docs MCP server](https://docs.envio.dev/docs/HyperIndex/mcp-server) --- # Migrate from Alchemy to Envio > Easily migrate your existing Alchemy subgraphs to Envio for faster indexing than subgraphs, multichain support, and a better developer experience. Migrating Alchemy subgraphs to Envio’s HyperIndex is a simple and developer-friendly process. Alchemy subgraphs follow The Graph’s model and HyperIndex uses a very similar structure, so most of your existing setup can carry over cleanly. If you're familiar with The Graph’s libraries, the migration process should be straightforward. You can also utilize tools like Cursor to speed things up. If you are new to HyperIndex, we strongly recommend starting with our [Quickstart](https://docs.envio.dev/docs/HyperIndex/quickstart) guide before you begin your migration from Alchemy. If you are new to the category entirely, see [what a blockchain indexer is](https://docs.envio.dev/blog/what-is-a-blockchain-indexer) for the wider context. ## Why Migrate to Envio’s HyperIndex? - **High-Speed Performance**: faster sync than subgraphs, measured in our [open benchmark](https://github.com/enviodev/open-indexer-benchmark) - **Lower Costs**: Reduced infrastructure requirements and operational expenses - **Better Developer Experience**: Simplified configuration and deployment - **Multichain Native**: Index data across multiple EVM chains through a single HyperIndex project - **Local Development**: Run your indexers locally for fast iteration and easier debugging - **White Glove Migration Support**: Get direct support from the Envio team for a smoother migration. - **GitOps Ready Deployments**: Link your GitHub repo and manage multiple deployments in a clean unified workflow - **Advanced Features**: Access to features like external calls and block handlers - **Seamless Integration**: Easily integrate existing GraphQL APIs and applications ## How to Migrate from Alchemy to Envio in 4 easy steps This Migration consists of 4 major steps: 1. Create a HyperIndex Project 2. subgraph.yaml Migration to config.yaml 3. schema.graphql Migration 4. Event Handler Migration ### Create a HyperIndex Project Start by spinning up a basic HyperIndex project with this command: ```bash pnpx envio init template --name alchemy-migration --directory alchemy-migration --template greeter --api-token "YOUR_ENVIO_API_KEY" ``` Once the project is created, drop your API key into the .env file and you’re good to go. ### subgraph.yaml Migration to config.yaml In HyperIndex, all project configuration lives in `config.yaml`. This is where you define contract addresses, the chains you want to index, and the specific events you want to track from those contracts. Below is an example showing how a Uniswap V4 subgraph.yaml maps to a HyperIndex `config.yaml` in a real migration. The Graph - `subgraph.yaml` ```yaml specVersion: 0.0.4 description: Uniswap is a decentralized protocol for automated token exchange on Ethereum. repository: https://github.com/Uniswap/v4-subgraph schema: file: ./schema.graphql features: - nonFatalErrors - grafting dataSources: - kind: ethereum/contract name: PositionManager network: mainnet source: abi: PositionManager address: "0xbD216513d74C8cf14cf4747E6AaA6420FF64ee9e" startBlock: 21689089 mapping: kind: ethereum/events apiVersion: 0.0.7 language: wasm/assemblyscript file: ./src/mappings/index.ts entities: - Position abis: - name: PositionManager file: ./abis/PositionManager.json eventHandlers: - event: Subscription(indexed uint256,indexed address) handler: handleSubscription - event: Unsubscription(indexed uint256,indexed address) handler: handleUnsubscription - event: Transfer(indexed address,indexed address,indexed uint256) handler: handleTransfer ``` HyperIndex - `config.yaml` ```yaml # yaml-language-server: $schema=./node_modules/envio/evm.schema.json name: uni-v4-indexer chains: - id: 1 start_block: 21689089 contracts: - name: PositionManager address: "0xbD216513d74C8cf14cf4747E6AaA6420FF64ee9e" events: - event: Subscription(uint256 indexed tokenId, address indexed subscriber) - event: Unsubscription(uint256 indexed tokenId, address indexed subscriber) - event: Transfer(address indexed from, address indexed to, uint256 indexed id) ``` If you hit any issues, check the [Configuration File](https://docs.envio.dev/docs/HyperIndex/configuration-file) docs or reach out to our team in [Discord](https://discord.gg/envio). ### schema.graphql Migration This step is simple. You keep most of the file as is. Remove all `@entity` directives from your entities, and check for the few things HyperIndex handles differently: `Int8` isn't supported (use `BigInt`), `interface` types aren't supported, and a list of entities such as `tokens: [Token!]!` needs `@derivedFrom`. See [Schema migration](https://docs.envio.dev/docs/HyperIndex/migration-guide#2-schema-migration) for details. ### Event Handler Migration This is the final step of the migration which consists of two parts: - Moving from AssemblyScript to TypeScript - Updating Subgraph syntax to HyperIndex syntax #### AssemblyScript to TypeScript HyperIndex uses TypeScript instead of AssemblyScript. Since AssemblyScript is a subset of TypeScript, you can simply copy most of your code over without worrying about major syntax changes. #### Subgraph to HyperIndex The HyperIndex workflow is very similar to Subgraphs, but there are a few important differences to keep in mind: - Replace `ENTITY.save()` with `context.ENTITY.set(VALUES)` - Handlers need to be async - Use `await` when loading entities As you start using HyperIndex, you’ll pick up the differences quickly. Here is a code snippet to give you a sense of what these changes look like in practice. The Graph - `eventHandler.ts` ```typescript export function handleSubscription(event: SubscriptionEvent): void { const subscription = new Subscribe(event.transaction.hash + event.logIndex); subscription.tokenId = event.params.tokenId; subscription.address = event.params.subscriber.toHexString(); subscription.logIndex = event.logIndex; subscription.blockNumber = event.block.number; subscription.position = event.params.tokenId; subscription.save(); } ``` HyperIndex - `eventHandler.ts` ```typescript import { indexer } from "envio"; indexer.onEvent( { contract: "PositionManager", event: "Subscription", // event.transaction is empty unless you select its fields fields: { transaction: ["hash"] }, }, async ({ event, context }) => { const entity = { id: event.transaction.hash + event.logIndex, tokenId: event.params.tokenId, address: event.params.subscriber, blockNumber: event.block.number, logIndex: event.logIndex, position: event.params.tokenId, }; context.Subscription.set(entity); }, ); ``` For a few extra tips on migrating from Alchemy to Envio, check out our other [migration guide](https://docs.envio.dev/docs/HyperIndex/migration-guide#extra-tips) in our docs. ## Share Your Learnings If you come across anything useful during your migration, share it with us in [Discord](https://discord.gg/envio) and help future developers. ## Getting Help Join our [Discord](https://discord.gg/envio) if you need support. It is the fastest way to get direct help from the team and the community. ---