SubQuery indexing Ethereum by Onfinality API

SubQuery indexing Ethereum by Onfinality API

Managed Service + API App

ยท

1 min read

Table of contents

No heading

No headings in the article.

  1. Installation environment for the subquery
  • Node.js

  • Docker & Docker-compose

  • Git (Usually comes with the Linux OS, maybe not need to install it.)

this guide can help you https://tonymoon.hashnode.dev/subquery-frontier-reseau-guide-par-tony

  1. Initialisation Ethereum project

    subql init ethereum-index

  2. Enter ethereum-index folder, then yarn install and codegen

    cd ethereum-index

    yarn install

    yarn codegen

  3. Take free API for Ethereum with your key from app.onfinality.io

  4. Modified project.yaml file

    • endpoint: "https://eth.api.onfinality.io/rpc?apikey=<your_key>"

    • startBlock: 15695385

nano project.yaml

  1. Build Ethereum project and run docker-compose

    yarn build

    docker-compose pull && docker-compose up

  2. Check this query at http://<your_host>:3000

    { query { transactions(first:2 orderBy:BLOCK_HEIGHT_ASC){ totalCount nodes{ id txHash blockHeight to from value contractAddress } } } }

  3. Stop docker-compose at your host, export SUBQL_ACCESS_TOKEN and publish to get CID

    docker-compose stop

    export SUBQL_ACCESS_TOKEN=<your_token>

    subql publish

  4. Create project at managedservice.subquery.network by using CID and check query at explorer.subquery.network

Ethereum indexing

You can also push your project to GitHub repo. Good Luck!

ย