iExec subgraph

Reading and aggregating complex data from blockchains can be slow and tedious, that's why developers build systems to index onchain data and redistribute it as web API.

The iExec's protocol is indexed by The Graph and can be explored with a GraphQL API.

The iExec Explorer is an example of an application built with the iExec subgraph.

GraphQL API

The subgraph can be queried through the GraphiQL interface

The GraphQL API is publicly available:

  • for queries: https://thegraph.bellecour.iex.ec/subgraphs/name/bellecour/poco-v5

  • for subscriptions: wss://ws-thegraph.bellecour.iex.ec/subgraphs/name/bellecour/poco-v5

This subgraph is hosted by iExec and shared across all developers.

Keep in mind that you must use efficient calls and caching policy when querying this subgraph to avoid being rate limited.

Examples queries

Protocol metrics

{
  protocol(id: "iExec") {
    appsCount
    datasetsCount
    workerpoolsCount
    dealsCount
    tasksCount
    completedTasksCount
    claimedTasksCount
  }
}

Try this query

Application latest usages

query appUsages($appAddress: String!) {
  app(id: $appAddress) {
    usages(orderBy: timestamp, orderDirection: desc) {
      dealid: id
      timestamp
      tasks {
        taskid: id
        status
      }
    }
  }
}

Try this query

Worker rewards an seizes

query workerRewardsAndSeizes($worker: String!) {
  rewards(
    where: { account: $worker }
    orderBy: timestamp
    orderDirection: desc
  ) {
    value
    timestamp
    task {
      taskid: id
    }
    transaction {
      txHash: id
    }
  }
  seizes(
    where: { account: $worker }
    orderBy: timestamp
    orderDirection: desc
  ) {
    value
    timestamp
    task {
      taskid: id
    }
    transaction {
      txHash: id
    }
  }
}

Try this query

FAQ

Here are some frequently asked questions about iExec's subgraph.

You may also find useful information on these resources:

How to find an item by its ethereum address?

Although an ethereum address has multiple valid formats, The Graph requires lowercase addresses.

How to get more than 100 items?

By default, query responses are limited to 100 items per collection. If you want to receive more, you can go up to 1000 items per collection and beyond that, you can paginate with:

someCollection(first: 1000, skip: <number>) { ... }

Can I rely on a subgraph to check the state of the protocol?

Subgraphs are built to quickly access a representation of onchain state through a friendly API.

Under the hood, a subgraph is a centralized system watching the blockchain events and indexing data in a database. Like any system, it may be subject to issues (bugs, sync problems...) and reflect an erroneous or outdated state of the onchain data.

However relying on a subgraph to read and display non critical data is fine, users must always check the onchain state before interacting with a contract.

Can I deploy my own instance?

The subgraph source code is publicly available on the GitHub repository. You can use it to deploy the subgraph on a graphnode connected to the iExec Sidechain.

Can I use mutations?

No, as the subgraph reflects the onchain data, GraphQL mutations are disabled. Changes only occurs when an onchain event is indexed.

Last updated