Get Started with Envio
Envio HyperIndex is an indexing framework for real-time and historical blockchain data on Rootstock and other EVM chains. You define the contracts and events to index, write handlers that turn those events into entities, and query the result through a GraphQL API. Envio is currently supported on: .
On Rootstock mainnet (chain ID 30), HyperIndex uses HyperSync, Envio's data retrieval layer, as its default data source. Handlers are written in TypeScript (the default) or ReScript. You can run an indexer locally, self-host it, or deploy it to Envio Cloud, Envio's managed hosting.
Developers can start from a template (for example, ERC20 or Greeter), or use contract import to generate an indexer from an existing contract. You pick a template from the list that envio init shows. The template source code is in the HyperIndex repository.
Prerequisites
The following are required for Envio:
- Node.js
or newer
- pnpm
- Docker Desktop
Docker is required only to run the Envio indexer locally. See Run your indexer.
You also need an Envio API token to use HyperSync. To create one, follow the API tokens guide, which walks through the Envio app step by step.
Run the Envio CLI
You don't need to install Envio globally. Run CLI commands with pnpx. For example, to see the available commands:
pnpx envio --help
The following files are required to run an Envio indexer:
- Configuration (
config.yaml) - GraphQL schema (
schema.graphql) - Event handlers (
src/handlers/)
envio init generates these files from the template or contract you choose. The templates are listed in the Choose an initialization option step below, next to the contract import options.
Contract import tutorial
This walkthrough creates an indexer from a contract that is already deployed on Rootstock. It gives you a basic indexer and a GraphQL API for your app.
Initialize your indexer
cd into the folder of your choice and run:
pnpx envio init
Enter a folder name for the project, or press Enter to use the current directory:
? Specify a folder name (ENTER to skip): (.)
Select Evm as the blockchain ecosystem:
? Choose blockchain ecosystem
> Evm
Svm
Fuel
[↑↓ to move, enter to select, type to filter]
Choose how to import the contract:
? Choose an initialization option
> From Address - Lookup ABI from block explorer
From ABI File - Use your own ABI file
Template: ERC20
Template: Greeter
Feature: External Calls
Feature: Factory Contract
[↑↓ to move, enter to select, type to filter]
The From Address option only needs the chain and the contract address. If the contract is verified, the CLI fetches the ABI from a block explorer.
The From ABI File option uses a JSON file that contains the contract ABI. Use it if the contract isn't verified. The steps below follow this option.
Enter the path to the JSON file that contains the ABI
? What is the path to your json abi file?
Choose which events to include in the config.yaml file
? Which events would you like to index?
> [x] Transfer(address indexed from, address indexed to, uint256 value)
[↑↓ to move, space to select one, → to all, ← to none, type to filter]
Specify which chain the contract is deployed on
Rootstock mainnet is listed as rsk. Type rsk to filter the list:
? Choose network: rsk
> rsk
[↑↓ to move, enter to select, type to filter]
Enter the name of the contract
? What is the name of this contract?
Enter the address of the contract
? What is the address of the contract?
[Use the proxy address if your abi is a proxy implementation]
📣Note: if you use a proxy contract with an implementation, the address should be for the proxy.
Select the continuation option
? Would you like to add another contract?
> I'm finished
Add a new address for same contract on same network
Add a new network for same contract
Add a new contract (with a different ABI)
[Current contract: Wrbtc, on network: rsk]
You can finish, or add more addresses for the same contract on the same network, the same contract on a different network, or a different contract.
Add your API token
? Add an Envio API token to your .env file?
> Create a new API token (Opens https://envio.dev/app/api-tokens)
Add an existing API token
[↑↓ to move, enter to select, type to filter]
You can also run contract import without prompts. Set your Envio API token in ENVIO_API_TOKEN so the CLI can write it to the .env file. For a verified contract on Rootstock mainnet:
ENVIO_API_TOKEN=<YOUR_API_TOKEN> pnpx envio init contract-import explorer -b rsk -c <CONTRACT_ADDRESS> --single-contract --all-events -n my-indexer -d my-indexer
For more information, see the HyperIndex quickstart.
Run your indexer
Make sure Docker is running, then start the indexer from the project folder:
pnpm dev
This opens the local Hasura console, where you can query the indexed data with GraphQL. The local admin password is testing. See running the indexer locally and deploying to Envio Cloud.
Envio indexer examples
See the HyperIndex tutorials for examples.
Get in touch
For technical questions, join the Envio Discord or email hello@envio.dev.