Skip to main content

Quickstart: EVM chains

The evm squid template indexes transactions to the "black hole" address 0x0000000000000000000000000000000000000000, persists its data into a Postgres database and serves it over a GraphQL API. It is intended to be a starter project for building a custom squid indexing logs and transactions data on Ethereum and other EVM chains.

Pre-requisites

Before getting to work on your very first squid, verify that you have installed the following:

  • Node v16.x or newer
  • Squid CLI v2.1.0 or newer
  • Docker
info

Earlier versions of the template were based on Makefile. The new version uses @subsquid/commands scripts, defined in commands.json that are automatically recognized as sqd sub-commands.

Please note:

  • The squid template is not compatible with yarn and expects a npm-generated package-lock.json file in the root.

Step 1: Scaffold from a template

Come up with a new memorable name for your squid and scaffold from squid-evm-template using sqd init:

sqd init my-awesome-squid --template evm
cd my-awesome-squid
info

Explore all available templates with sqd init --help. You may choose the gravatar template as a starting point for indexing EVM smart contracts as well.

Step 2: Install dependencies

npm ci

Step 3: Set the network

Inspect src/processor.ts and set the EVM network of interest. Consult the processor configuration page for the list of supported networks and configuration options.

Step 4: Build the squid

sqd build

Step 5: Launch Postgres and detach

sqd up

Step 6: Inspect and run the processor

The squid fetches, aggregates and persists burn transactions in the processor.run() method. The Burn entity is defined in schema.graphql, and the TypeORM model class used by this template was generated with sqd codegen. You can learn more about this in the squid development section.

Let's run the processor:

sqd process

It outputs simple aggregations of the burned ETH and batch-inserts the tx data into the Postgres database.

Step 7: Start the GraphQL server

This should be run in a separate terminal window:

sqd serve
# in yet another window
sqd open http://localhost:4350/graphql

This starts a GraphQL API console auto-serving the Burn entity data we are uploading to Postgres. For example, one can explore the top-10 historical burns:

query MyQuery {
burns(orderBy: value_DESC) {
address
block
id
txHash
value
}
}

Step 8: Customize

Hack the schema file schema.graphql and the processor src/processor.ts to index the data your way!

What's next?