Skip to main content
Version: ArrowSquid

Running squids locally (quest edition)

This tutorial should help new Subsquid testnet users get their first squids up and running locally.

Installing dependencies

  1. Enable Hyper-V.
  2. Install Docker for Windows.
  3. Install NodeJS LTS using the official installer.
  4. Install Git for Windows.

In all installs it is OK to leave all the options at their default values. You will need a terminal to complete this tutorial - WSL bash is the preferred option.

Installing Subsquid CLI

Open a terminal and run

npm install --global @subsquid/cli@latest

This adds the sqd command. Verify that the installation was successful by running

sqd --version

A healthy response should look similar to

@subsquid/cli/2.5.0 linux-x64 node-v20.5.1

Running a simple squid

  1. Think of a good, globally unique name for your new squid. Now open a terminal and run the following commands to create the squid and enter its folder:

    sqd init my-awesome-squid -t https://github.com/subsquid-labs/quest-single-chain-squid
    cd my-awesome-squid

    Replace my-awesome-squid with the name you chose for your squid. If a squid with that name already exists, the first command will throw an error; if that happens simply think of another name and repeat the commands.

  2. Download your squid deployment key and save it to the ./query-gateway/keys subfolder of the squid folder. The file will be used by the query gateway container.

  3. The template squid uses a PostgreSQL database and a query gateway. Start Docker containers that run these with

    sqd up
  4. Prepare the squid for running by installing dependencies, building the source code and creating all the necessary database tables:

    npm ci
    sqd build
    sqd migration:apply
  5. Start your squid with

    sqd run .

    The command should output lines like these:

    [api] 09:56:02 WARN  sqd:graphql-server enabling dumb in-memory cache (size: 100mb, ttl: 1000ms, max-age: 1000ms)
    [api] 09:56:02 INFO sqd:graphql-server listening on port 4350
    [processor] 09:56:04 INFO sqd:processor processing blocks from 6000000
    [processor] 09:56:05 INFO sqd:processor using archive data source
    [processor] 09:56:05 INFO sqd:processor prometheus metrics are served at port 33097
    [processor] 09:56:08 INFO sqd:processor:mapping Burned 59865654 Gwei from 6000000 to 6016939
    [processor] 09:56:08 INFO sqd:processor 6016939 / 17743832, rate: 5506 blocks/sec, mapping: 304 blocks/sec, 182 items/sec, eta: 36m

    The squid should sync in 10-15 minutes. When it's done, stop it with Ctrl-C, then stop and remove the auxiliary containers with

    sqd down

Running multiprocessor squids

Redo the previous section using a special multichain squid template prepared for the quest. This change will only affect the first two commands:

sqd init my-awesome-multichain-squid -t <multiprocessor_squid_template>
cd my-awesome-multichain-squid

Here, my-awesome-multichain-squid is a placeholder for the name you should choose for your awesome multiprocessor squid and <multiprocessor_squid_template> is one of the following:

  • https://github.com/subsquid-labs/quest-double-chain-squid
  • https://github.com/subsquid-labs/quest-triple-chain-squid
  • https://github.com/subsquid-labs/quest-quad-chain-squid

Note that you need to use a different key for your multichain squids. Grab it from the Aquarium quests page.

The rest of the commands do not need to be changed. An output of a healthy double chain template squid looks like this:

[api] 10:05:05 WARN  sqd:graphql-server enabling dumb in-memory cache (size: 100mb, ttl: 1000ms, max-age: 1000ms)
[api] 10:05:05 INFO sqd:graphql-server listening on port 4350
[bsc-processor] 10:05:07 INFO sqd:processor processing blocks from 27000000
[eth-processor] 10:05:07 INFO sqd:processor processing blocks from 16000000
[bsc-processor] 10:05:08 INFO sqd:processor using archive data source
[bsc-processor] 10:05:08 INFO sqd:processor prometheus metrics are served at port 44305
[eth-processor] 10:05:08 INFO sqd:processor using archive data source
[eth-processor] 10:05:08 INFO sqd:processor prometheus metrics are served at port 39751
[eth-processor] 10:05:10 INFO sqd:processor 16003899 / 17743832, rate: 1482 blocks/sec, mapping: 616 blocks/sec, 1154 items/sec, eta: 20m
[bsc-processor] 10:05:11 INFO sqd:processor 27002719 / 30168778, rate: 787 blocks/sec, mapping: 542 blocks/sec, 1041 items/sec, eta: 1h 8m

You need to wait for all processors to sync to complete the quest. The ETA for the double chain template is 25-40 minutes.