For AI agents: the documentation index is at /llms.txt. Markdown versions of pages are available by appending .md to the URL.
Skip to main content

Scaffold-Eth-2 Envio Extension

Introduction​

The Scaffold-ETH 2 Envio extension makes indexing your deployed smart contracts as simple as possible. Generate a boilerplate indexer for your deployed contracts with a single click and start indexing their events immediately.

With this extension, you get:

  • 🔍 Automatic indexer generation from your deployed contracts
  • 📊 Status dashboard with links to Envio metrics and database
  • 🔄 One-click regeneration to update the indexer when you deploy new contracts
  • 📈 GraphQL API for querying your indexed blockchain data

Prerequisites​

Before starting, ensure you have the following installed:

  • Node.js v22

    v22.15.0 or newer required

  • Docker Desktop

    required to run the Envio indexer locally

  • Yarn

    for Scaffold-ETH and the Envio indexer; enable it with corepack enable yarn

Step 1: Create a New Scaffold-ETH 2 Project with Envio Extension​

To create a new Scaffold-ETH 2 project with the Envio extension already integrated:

npx create-eth@latest -e enviodev/scaffold-eth-2-extension

The CLI asks for a project name and a Solidity framework (Hardhat or Foundry). The steps below use the project name you choose.

If you pick Foundry, install Foundry first. create-eth stops with FoundryValidationError when forge and anvil aren't on your PATH.

Step 2: Start the Local Blockchain​

Navigate to your project directory and start the local blockchain:

cd your-project-name
yarn chain

This will start a local blockchain node for development: Hardhat or Anvil, depending on the framework you picked, with chain ID 31337 at http://127.0.0.1:8545. See Local chain - Hardhat and Local chain - Anvil for how an indexer reads it.

Step 3: Deploy Your Contracts​

In a new terminal window, navigate to your project directory and deploy the default smart contracts:

cd your-project-name
yarn deploy

This will deploy the default contracts to the local blockchain. You can skip this for now and deploy your own contracts with yarn deploy later, but the indexer has nothing to index until something is deployed.

Step 4: Start Scaffold-ETH Frontend​

From your project directory, start the Scaffold-ETH frontend:

yarn start

This will start the Scaffold-ETH frontend at http://localhost:3000.

Step 5: Generate the Indexer​

Navigate to the Envio page in your Scaffold-ETH frontend at http://localhost:3000/envio and click the "Generate" button. This will create the boilerplate indexer from your deployed contracts. Do this after every yarn deploy, including the first deploy of the default YourContract: the config.yaml the extension ships only has the address of the default Hardhat deployment, so it won't match a Foundry deployment or your own contracts.

Scaffold-ETH 2 Envio Dashboard

The Envio page also includes a helpful "How to Use" section with step-by-step instructions.

Step 6: Start the Indexer​

Navigate to the Envio package directory and start the indexer:

cd packages/envio
yarn dev

This will begin indexing your contract events. The root yarn install that create-eth ran already installed the indexer's dependencies, because packages/envio is a Yarn workspace.

The local chain (ID 31337) isn't on HyperSync, so the indexer reads it over RPC and doesn't need an ENVIO_API_TOKEN. You only need to copy packages/envio/.env.example to .env and add a token if you add a chain that HyperSync serves.

Regenerating the Indexer​

When you deploy new contracts or make changes to existing ones, you'll need to regenerate the indexer:

Via Frontend Dashboard​

  1. Go to the Envio page at http://localhost:3000/envio
  2. Click "Generate" to regenerate the boilerplate indexer

Via Command Line​

cd packages/envio
yarn run update
Note

Regenerating will overwrite any custom handlers, config, and schema changes, creating a fresh boilerplate indexer based on your deployed contracts. After regenerating, you'll need to stop the running indexer (Ctrl+C) and restart it with yarn dev for the changes to take effect.