Third-party docsEnvio

Quickstart: Index Arbitrum data with Envio

Learn how to create a GraphQL API for your Arbitrum smart contracts with Envio HyperIndex and query Arbitrum data with HyperSync

Request an update

Envio HyperIndex

Envio HyperIndex is an indexing framework for real-time and historical onchain data. You define the contracts and events to index, write handlers that turn those events into entities, and query the results through a GraphQL API.

HyperIndex supports Arbitrum One, Arbitrum Nova, and Arbitrum Sepolia through HyperSync. It can also index any other EVM chain, including your own Arbitrum chain, by using an RPC data source.

You write handlers 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.

Envio HyperSync

HyperSync is Envio's data retrieval layer, used as an alternative to JSON-RPC. HyperIndex uses HyperSync as its default data source on supported chains, so you don't need to configure RPC URLs or handle rate limits.

HyperSync is also available as a standalone API. You can query it with the Python, Rust, Node.js, and Go clients, or through HyperRPC, its JSON-RPC interface.

NetworkChain IDHyperSync URL
Arbitrum One42161https://arbitrum.hypersync.xyz
Arbitrum Nova42170https://arbitrum-nova.hypersync.xyz
Arbitrum Sepolia421614https://arbitrum-sepolia.hypersync.xyz

HyperSync requires an API token. You can create one in the Envio app.

HyperIndex key features

  • Contract import: Generate an indexer from a verified contract address or a local ABI file.
  • Multichain indexing: Index several chains into one database and query them through one GraphQL API. See multichain indexing.
  • Factory contracts: Index contracts that are created by other contracts at runtime. See dynamic contracts.
  • Reorg handling: Keep indexed data consistent with the chain when blocks are reorganized. This is on by default. See reorg support.

Prerequisites

Create an indexer with contract import

This walkthrough creates an indexer and a GraphQL API from a contract that is already deployed and verified on Arbitrum.

Initialize your indexer

Run the following command in the folder of your choice:

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

Select From Address - Lookup ABI from block explorer as the initialization option:

? 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

The From Address option fetches the contract ABI from a block explorer. If the CLI can't fetch the ABI, for example, because the contract isn't verified, select From ABI File and enter the path to a JSON file that contains the ABI.

Select the chain the contract is deployed on

Select the chain, for example, arbitrum-one or arbitrum-sepolia. You can type to filter the list:

? Which blockchain would you like to import a contract from?
abstract
amoy
arbitrum-nova

> arbitrum-one
> arbitrum-sepolia
> arbitrum-testnet
> v aurora
> [↑↓ to move, enter to select, type to filter]

Enter the contract address

? What is the address of the contract?
[Use the proxy address if your abi is a proxy implementation]

If your contract is a proxy, enter the proxy address, not the implementation address.

Choose the events to index

The CLI lists the events from the contract ABI and selects all of them by default:

? Which events would you like to index?

> [x] Approval(address indexed owner, address indexed spender, uint256 value)
> [x] Transfer(address indexed from, address indexed to, uint256 value)
> [↑↓ to move, space to select one, → to all, ← to none, type to filter]

Finish or add more contracts

? 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)

You can add more addresses for the same contract, the same contract on another chain, or a different contract.

Add your API token

The CLI then asks you to add an Envio API token to the project's .env file. You can create a new token or add an existing one.

The command generates the following files:

- `config.yaml`: the chains, contracts, and events to index
- `schema.graphql`: the entities stored in the database
- `src/handlers/`: the event handlers

You can also run contract import without prompts. For example, for a contract on Arbitrum One:

pnpx envio init contract-import explorer -b arbitrum-one -c <CONTRACT_ADDRESS> --single-contract --all-events -n my-indexer -d my-indexer

For more detail, 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.

To deploy the indexer, see deploying to Envio Cloud.

Envio examples

Getting help

How is this guide?

On this page