Skip to main content

Cronos Quick Start

SubQuery TeamAbout 5 min

Cronos Quick Start


The goal of this quick start guide is to adapt the standard starter project in the Cronos Network and then begin indexing all transfers of Cro Crow Tokenopen in new window.


Cronos is an EVM compatible (Ethermint) chain, as such there are two options for indexing Cronos data. You can index chain data via the standard Cosmos RPC interface, or via Ethereum APIs. For Cronos, we provide a starter project for each.

Before we begin, make sure that you have initialised your project using the provided steps in the Start Here section. You must complete the suggested 4 stepsopen in new window for Cosmos users.

Now, let's move ahead in the process and update these configurations.

Previously, in the 1. Create a New Project section, you must have noted 3 key files. Let's begin updating them one by one.


The final code of this project can be found hereopen in new window.

1. Your Project Manifest File

The Project Manifest (project.yaml) file is an entry point to your project. It defines most of the details on how SubQuery will index and transform the chain data. For Cosmos chains, there are four types of mapping handlers (and you can have more than one in each project):

  • BlockHanders: On each and every block, run a mapping function
  • TransactionHandlers: On each and every transaction, run a mapping function
  • MessageHandlers: On each and every message that matches optional filter criteria, run a mapping function
  • EventHanders: On each and every event that matches optional filter criteria, run a mapping function

Note that the manifest file has already been set up correctly and doesn’t require significant changes, but you need to change the datasource handlers. This section lists the triggers that look for on the blockchain to start indexing.


There are two versions of this file depending on your choice to index data via the ETH or Cosmos RPC

  - kind: ethereum/Runtime
    startBlock: 5120574 #NoteCro Crow Token started at 946
      abi: erc20
      address: "0xE4ab77ED89528d90E6bcf0E1Ac99C58Da24e79d5" #Cro Crow Token
        file: ./cro-crow.abi.json #ABI interface file specific for Cro Crow Token
      file: ./dist/index.js
        - handler: handleTransfer
          kind: ethereum/LogHandler
              - "Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
              - null
              - null
              - null

The above code defines that you will be running a handleTransfer mapping function whenever there is an event emitted with the transfer method. Check out our Manifest File documentation to get more information about the Project Manifest (project.yaml) file.


Please note that Cro Crow token requires a specific ABI interface. You need to:

2. Update Your GraphQL Schema File

The schema.graphql file determines the shape of the data that you are using SubQuery to index, hence it's a great place to start. The shape of your data is defined in a GraphQL Schema file with various GraphQL entities.

Update the schema.graphql file as follows. The aim is to index all transfers of Cro Crow Tokenopen in new window.

type Transfer @entity {
  id: ID! # Transfer hash
  from: String!
  to: String!
  tokenId: BigInt!


When you make any changes to the schema file, do not forget to regenerate your types directory.

yarn codegen

You will find the generated models in the /src/types/models directory.

If you're creating as an CosmWasm based project, this command will also generate types for your listed protobufs and save them into src/types directory, providing you with more typesafety. Read about how this is done in Cosmos Codegen from CosmWasm Protobufs.

If you're creating as an EVM based project, this command will also generate ABI types and save them into src/types using the npx typechain --target=ethers-v5 command, allowing you to bind these contracts to specific addresses in the mappings and call read-only contract methods against the block being processed.

It will also generate a class for every contract event to provide easy access to event parameters, as well as the block and transaction the event originated from. Read about how this is done in EVM Codegen from ABIs.

Check out our GraphQL Schema documentation to get more information on schema.graphql file.

Now that you have made essential changes to the GraphQL Schema file, let’s go ahead with the next configuration.

3. Add a Mapping Function

Mapping functions determine how chain data is transformed into the optimised GraphQL entities that you previously defined in the schema.graphql file.

Navigate to the default mapping function in the src/mappings directory. You will see setup types for ABI TransferEventArgs and ApproveCallArgs. Delete those for approvals. You will also see two exported functions: handleEthermintEvmEvent & handleEthermintEvmCall or handleLog & handleTransaction. Delete them as well.


There are two versions of this file depending on your choice to index data via the ETH or Cosmos RPC

Update your mapping files to match the following (note the additional imports):

import { Transfer } from "../types";
import { EthereumLog } from "@subql/types-ethereum";
import { BigNumber } from "@ethersproject/bignumber";

// Setup types from ABI
type TransferEventArgs = [string, string, BigNumber] & {
  from: string;
  to: string;
  tokenId: BigNumber;

// Save all transfers
export async function handleTransfer(
  log: EthereumLog<TransferEventArgs>
): Promise<void> {
  const transfer = Transfer.create({
    id: log.transactionHash,
    from: log.args.from,
    tokenId: log.args.tokenId.toBigInt(),


Let’s understand how the above code works. Here, the function receives an EthereumLog or EthermintEvmEvent which includes data on the payload. We extract this data and then create a new Transfer entity defined earlier in the schema.graphql file. After that we use the .save() function to save the new entity (SubQuery will automatically save this to the database). Check out our Mappings documentation and get information on the mapping functions in detail.

4. Build Your Project

Next, build your work to run your new SubQuery project. Run the build command from the project's root directory as given here:

yarn build


Whenever you make changes to your mapping functions, you must rebuild your project.

Now, you are ready to run your first SubQuery project. Let’s check out the process of running your project in detail.

5. Run Your Project Locally with Docker

Whenever you create a new SubQuery Project, never forget to run it locally on your computer and test it. And using Docker is the most hassle-free way to do this.

docker-compose.yml file defines all the configurations that control how a SubQuery node runs. For a new project, which you have just initialised, no major changes are needed.

However, visit the Running SubQuery Locally to get more information on the file and the settings.

Run the following command under the project directory:

yarn start:docker


It may take a few minutes to download the required images and start the various nodes and Postgres databases.

6. Query your Project

Next, let's query our project. Follow these three simple steps to query your SubQuery project:

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

  2. You will see a GraphQL playground in the browser and the schemas which are ready to query.

  3. Find the Docs tab on the right side of the playground which should open a documentation drawer. This documentation is automatically generated and it helps you find what entities and methods you can query.

Try the following query to understand how it works for your new SubQuery starter project. Don’t forget to learn more about the GraphQL Query language.

  query {
    transfers(first: 5) {
      nodes {

You will see the result similar to below:

  "data": {
    "transfers": {
      "nodes": [
          "id": "0xff2bcbf7445c48f95b9e9bb770076e1562db2b58881338ea65c8c60aae1f4d20",
          "from": "0xe40E86209bf7A563B23dc5625ea968F9DD9269fA",
          "to": "0x281c2b2a0d5a3db358356537Fb4E1ac6Df9715f0",
          "tokenId": "1160"
          "id": "0xfbc0594cde0776813f02804e816ecd153f0a3e201523479f93f85b5423e5e1c6",
          "from": "0x9B94F48372f5ED14f860B86f606ffb61D908E4dC",
          "to": "0x05d6889ea1593b6e58B3366A95Ac923FC00A37AA",
          "tokenId": "4921"
          "id": "0xc601f604b5c3a6c78257b0e946429d7085c7a9f04b4c985d499c1118465bc30f",
          "from": "0x00779809C0089d269C719F5953F7528E4dcE1Bdc",
          "to": "0x45DfaDC5e74f8Fb62Be7893aA7c1f34db7C26D8d",
          "tokenId": "7085"


The final code of this project can be found hereopen in new window.

What’s Next?

Congratulations! You have now a locally running SubQuery project that accepts GraphQL API requests for transferring data from bLuna.

Click here to learn what should be your next step in your SubQuery journey.