Skip to content

Latest commit

 

History

History
105 lines (82 loc) · 3.72 KB

README.md

File metadata and controls

105 lines (82 loc) · 3.72 KB

SubQuery - Zksync

Not deployed yet

Start

First, install SubQuery CLI globally on your terminal by using NPM npm install -g @subql/cli

You can either clone this GitHub repo, or use the subql CLI to bootstrap a clean project in the network of your choosing by running subql init and following the prompts.

Don't forget to install dependencies with npm install or yarn install!

Editing your SubQuery project

Although this is a working example SubQuery project, you can edit the SubQuery project by changing the following files:

  • The project manifest in project.ts defines the key project configuration and mapping handler filters
  • The GraphQL Schema (schema.graphql) defines the shape of the resulting data that you are using SubQuery to index
  • The Mapping functions in src/mappings/ directory are typescript functions that handle transformation logic

SubQuery supports various layer-1 blockchain networks and provides dedicated quick start guides as well as detailed technical documentation for each of them.

Run your project

If you get stuck, find out how to get help below.

The simplest way to run your project is by running yarn dev or npm run-script dev. This does all of the following:

  1. yarn codegen - Generates types from the GraphQL schema definition and contract ABIs and saves them in the /src/types directory. This must be done after each change to the schema.graphql file or the contract ABIs
  2. yarn build - Builds and packages the SubQuery project into the /dist directory
  3. docker-compose pull && docker-compose up - Runs a Docker container with an indexer, PostgreSQL DB, and a query service. This requires Docker to be installed and running locally. The configuration for this container is set from your docker-compose.yml

You can observe the three services start, and once all are running (it may take a few minutes on your first start), please open your browser and head to http://localhost:3000 - you should see a GraphQL playground showing with the schemas ready to query. Read the docs for more information or explore the possible service configuration for running SubQuery.

Query your project

For this project, you can try to query with the following GraphQL code to get a taste of how it works.

{
  accounts (first: 1) {
    nodes {
      id
      ERC721operatorOwner {
        nodes {
          ownerId
        }
      }
      asAccessControl {
        id
      }
      asAccessControlId
      accessControlsByAsAccountId {
        nodes {
          roles {
            nodes {
              roleId
              role {
                id
              }
            }
          }
        }
      }
      ERC721tokens {
        nodes {
          id
          ownerId
          identifier
          content
        }
      }
    }
  }
  
  eRC721Tokens {
    nodes {
      id
      contractId
      identifier
      uri
      timestamp
      content
      channel
      owner {
        id
      }
    }
  }
  
  roles {
    nodes {
      id
    }
  }
}

You can explore the different possible queries and entities to help you with GraphQL using the documentation draw on the right.

Publish your project

SubQuery is open-source, meaning you have the freedom to run it in the following three ways: