Skip to content

octalmage/jax-indexer

Repository files navigation

SubQuery - Starter Package for Cosmos/Juno

A basic Cosmos (based on Juno) example project with an event and message handler. Read more about SubQuery support for Cosmos at https://academy.subquery.network/quickstart/quickstart_chains/cosmos.html.

The Starter Package is an example that you can use as a starting point for developing your SubQuery project.

A SubQuery package defines which data SubQuery will index from the blockchain, and how it will store it.

This Starter Package by default allows indexing events and messages from Juno.

Preparation

Environment and dependencies

  • Typescript is required to compile project and define types.

  • Both SubQuery CLI and generated Project have dependencies and require Node.

  • You will also need Yarn or NPM and Docker.

Install the SubQuery CLI and Project Dependencies

Install SubQuery CLI globally on your terminal by using NPM (we don't recommend using Yarn to install global dependencies):

npm install -g @subql/cli

Under the project directory, install the node dependencies by running the following command (Learn more):

yarn OR npm install

Configure the Project Further

If you want to change your project you will need to work on the following files:

  • The Manifest in project.yaml to configure your project
  • The GraphQL Schema in schema.graphql to define shape of the data
  • The Mapping functions in src/mappings/ directory to transform data coming from blockchain

Learn more

Build the Project

1. Generate Associated Typescript

We will generate the defined entity models with the following command:

yarn codegen OR npm run-script codegen

If you change any data in your schema.graphql, you should run this command again. You should also consider deleting your local database in the .data/ directory.

2. Build the project

This builds your project into static files within the /dist for running.

yarn build OR npm run-script codegen

If you change any data in your src/mappings/ directory you should run this command again.

Indexing and Query

1. Run Docker

Under the project directory run following command:

yarn start:docker

This will download packages from Docker, create a new Postgres database, and start an indexing an query service. When you first run this, it may take some time to start, please be patient.

2. Query this Project

Open your browser and head to http://localhost:3000.

Finally, you should see a GraphQL playground is showing in the explorer and the schemas that ready to query. On the right hand side is a documentation button that shows you what models you have to construct queries.

With this project can try to query with the following code to get a taste of how it works.7

{
  query {
    executeEvents(first: 5) {
      nodes {
        id
        blockHeight
        txHash
        contractAddress
      }
    }
    messages(first: 5) {
      nodes {
        id
        blockHeight
        txHash
        sender
        contract
      }
    }
  }
}

Useful Resources

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published