Skip to main content
Version: Old ArrowSquid docs

Quickstart: EVM chains

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

Pre-requisites

info

With the exception of sqd init, sqd commands mentioned here are just scripts defined in commands.json that the sqd executable automatically discovers. Take a look at the contents of this file to learn more about how squids work under the hood.

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 supported networks and processor configuration pages.

Step 4: Launch Postgres and detach

sqd up

Step 5: 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 6: Start the GraphQL server

Run the API server in a separate terminal window, then visit the GraphiQL console:

sqd serve

The console auto-serves 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 7: Customize

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

What's next?