You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Environment variables are a crucial part of configuring your Envio indexer. They allow you to manage sensitive information and configuration settings without hardcoding them in your codebase.
11
+
12
+
## Naming Convention
13
+
14
+
All environment variables used by Envio must be prefixed with `ENVIO_`. This naming convention:
15
+
- Prevents conflicts with other environment variables
16
+
- Makes it clear which variables are used by the Envio indexer
17
+
- Ensures consistency across different environments
18
+
19
+
## Example Environment Variables
20
+
21
+
Here are some commonly used environment variables:
When using the Envio Hosted Service, you can configure environment variables through the Envio platform's dashboard. Remember that all variables must still be prefixed with `ENVIO_`.
56
+
57
+
For more information about environment variables in the hosted service, see the [Hosted Service documentation](../HyperIndex/hosted-service).
58
+
59
+
## Configuration File
60
+
61
+
For use of environment variables in your configuration file, read the docs here: [Configuration File](../HyperIndex/configuration-file).
62
+
63
+
## Best Practices
64
+
65
+
1.**Never commit sensitive values**: Always use environment variables for sensitive information like API keys and database credentials
66
+
1.**Never commit or use private keys**: Never commit or use private keys in your codebase
67
+
1.**Use descriptive names**: Make your environment variable names clear and descriptive
68
+
1.**Document your variables**: Keep a list of required environment variables in your project's README
69
+
1.**Use different values**: Use different environment variables for development, staging, and production environments
70
+
1.**Validate required variables**: Check that all required environment variables are set before starting your indexer
71
+
72
+
## Troubleshooting
73
+
74
+
If you encounter issues with environment variables:
75
+
76
+
1. Verify that all required variables are set
77
+
2. Check that variables are prefixed with `ENVIO_`
78
+
3. Ensure there are no typos in variable names
79
+
4. Confirm that the values are correctly formatted
80
+
81
+
For more help, see our [Troubleshooting Guide](../HyperIndex/logging).
Copy file name to clipboardExpand all lines: docs/HyperIndex/migration-guide.md
+180-9Lines changed: 180 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
1
---
2
2
id: migration-guide
3
-
title: Migrate from TheGraph and Other Indexers to HyperIndex
3
+
title: Migrate from a Subgraph to HyperIndex
4
4
sidebar_label: Migrate from TheGraph
5
5
slug: /migration-guide
6
6
---
7
7
8
-
# Migrate from TheGraph and Other Indexers to HyperIndex
8
+
# Migrate from TheGraph to HyperIndex
9
9
10
-
:::caution
11
-
**This guide is currently under construction**
12
-
13
-
We're actively working on comprehensive migration documentation. In the meantime, please reach out to our team on [Discord](https://discord.gg/envio) for personalized migration assistance.
10
+
:::info
11
+
Please reach out to our team on [Discord](https://discord.gg/envio) for personalized migration assistance.
14
12
:::
15
13
16
14
## Introduction
17
15
18
-
Migrating to HyperIndex from other indexing solutions is generally straightforward, and our team is actively working to reduce friction even further. Whether you're coming from TheGraph, Subsquid, Ponder, or a custom-built indexer, we have tools and processes to make your transition smooth and efficient.
16
+
Migrating from a subgraph to HyperIndex is designed to be a developer-friendly process. HyperIndex draws strong inspiration from TheGraph’s subgraph architecture, which makes the migration simple, especially with the help of coding assistants like Cursor and AI tools (don't forget to use our ai friendly docs [llm-docs.envio.dev](https://llm-docs.envio.dev)).
17
+
18
+
The process is simple but requires a good understanding of the underlying concepts. If you are new to HyperIndex, we recommend starting with the [Getting Started](../HyperIndex/getting-started) guide.
19
19
20
20
## Why Migrate to HyperIndex?
21
21
@@ -25,10 +25,181 @@ Migrating to HyperIndex from other indexing solutions is generally straightforwa
25
25
-**Advanced Features**: Access to capabilities not available in other indexing solutions
26
26
-**Seamless Integration**: Easy integration with existing GraphQL APIs and applications
27
27
28
+
## Subgraph to HyperIndex Migration Overview
29
+
30
+
Migration consists of three major steps:
31
+
1. Subgraph.yaml migration
32
+
1. Schema migration - near copy paste
33
+
1. Event handler migration
34
+
35
+
At any point in the migration run
36
+
37
+
`pnpm envio codegen`
38
+
39
+
to verify the `config.yaml` and `schema.graphql` files are valid.
40
+
41
+
or run
42
+
43
+
`pnpm dev`
44
+
45
+
to verify the indexer is running and indexing correctly.
46
+
47
+
### 0.5 Use `npx envio init` to generate a boilerplate
48
+
49
+
As a first step, we recommend using `npx 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.
50
+
51
+
### 1. `subgraph.yaml` → `config.yaml`
52
+
53
+
`npx envio init` will generate this for you. It's a simple configuration file conversion. Effectively specifying which contracts to index, which networks to index (multiple networks can be specified with envio) and which events from those contracts to index.
54
+
55
+
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.
56
+
57
+
58
+
<divclassName="row">
59
+
<divclassName="col col--6">
60
+
theGraph - `subgraph.yaml`
61
+
```yaml
62
+
specVersion: 0.0.4
63
+
description: Uniswap is a decentralized protocol for automated token exchange on Ethereum.
1. Converting the subgraph syntax to HyperIndex syntax
133
+
134
+
### 3.1 Converting Assemblyscript to Typescript
135
+
136
+
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.
137
+
138
+
### 3.2 Converting the subgraph syntax to HyperIndex syntax
139
+
140
+
There are some subtle differences in the syntax of the subgraph and HyperIndex. Including but not limited to the following:
141
+
142
+
- Replace Entity.save() with context.Entity.set()
143
+
- Convert to async handler functions
144
+
- Use `await` for loading entities `const x = await context.Entity.get(id)`
145
+
- Use [dynamic contract registration](../HyperIndex/configuration-file#dynamic-contracts) to register contracts
146
+
147
+
The below code snippets can give you a basic idea of what this difference might look like.
148
+
149
+
<div className="row">
150
+
<div className="col col--6">
151
+
theGraph - `eventHandler.ts`
152
+
```typescript
153
+
export function handleSubscription(event: SubscriptionEvent): void {
154
+
const subscription = new Subscribe(event.transaction.hash + event.logIndex)
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:
189
+
190
+
- Use the `field_selection` option to add additional fields to your index. Doc here: [field selection](../HyperIndex/configuration-file#field-selection)
191
+
- Use the `unordered_multichain_mode` option to enable unordered multichain mode, this is the most common need for multichain indexing. However comes with tradeoffs worth understanding. Doc here: [unordered multichain mode](../HyperIndex/configuration-file#unordered-multichain-mode)
192
+
- Use wildcard indexing to index by event signatures rather than by contract address.
193
+
- HyperIndex uses the standard graphql query language, where as the subgraph uses a custom query language. You can read about the slight nuances [here](https://docs.sablier.com/api/caveats). (We are working on a basic tool to help with backwards compatibility, please check in with us on discord for it's current status).
194
+
- Loaders are a powerful feature to optimize historical sync performance. You can read more about them [here](../HyperIndex/loaders).
195
+
- 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](../HyperIndex/loaders#effect-api-experimental)
196
+
197
+
## Share Your Learnings
198
+
199
+
If you discover helpful tips during your migration, we’d love contributions! Open a [PR](https://github.com/enviodev/docs) to this guide and help future developers.
200
+
28
201
## Getting Help
29
202
30
203
**Join Our Discord**: The fastest way to get personalized help is through our [Discord community](https://discord.gg/envio).
31
204
32
-
## Stay Tuned
33
205
34
-
We're working hard to provide detailed, step-by-step migration guides for all major indexing solutions. Stay tuned for more comprehensive documentation coming soon!
|**HyperSync URL Endpoint**|[https://chiliz.hypersync.xyz](https://chiliz.hypersync.xyz) or [https://8888.hypersync.xyz](https://8888.hypersync.xyz)|
16
-
|**HyperRPC URL Endpoint**|[https://chiliz.rpc.hypersync.xyz](https://chiliz.rpc.hypersync.xyz) or [https://8888.rpc.hypersync.xyz](https://8888.rpc.hypersync.xyz)|
14
+
|**Chiliz Chain ID**|88888|
15
+
|**HyperSync URL Endpoint**|[https://chiliz.hypersync.xyz](https://chiliz.hypersync.xyz) or [https://88888.hypersync.xyz](https://88888.hypersync.xyz)|
16
+
|**HyperRPC URL Endpoint**|[https://chiliz.rpc.hypersync.xyz](https://chiliz.rpc.hypersync.xyz) or [https://88888.rpc.hypersync.xyz](https://88888.rpc.hypersync.xyz)|
17
17
18
18
---
19
19
@@ -39,7 +39,7 @@ To get started, see our documentation or follow our quickstart [guide](/docs/Hyp
39
39
name: IndexerName # Specify indexer name
40
40
description: Indexer Description # Include indexer description
41
41
networks:
42
-
- id: 8888# Chiliz
42
+
- id: 88888# Chiliz
43
43
start_block: START_BLOCK_NUMBER # Specify the starting block
0 commit comments