Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Top Level Queries

Akhila Raju edited this page Jul 27, 2018 · 11 revisions

The following fields are root fields that can be retrieved at the top level of EthQL. Each root field, except for the server health field, have subfields that can queried. For simplicity sake, we show the root field with only one subfield queried in these examples. To see all of the subfields available, please take a look at the Query Fields sections in the Query Handbook.

Select a single block

Select a single block by one of the following: number: BlockNumber, tag: string, or hash: string.

{
  block(number: 1234) {
    hash
  }
}

The example query above returns the following:

{
  block: { 
    hash: "0x624d6c50f4edff05693806953b211050ef3e674ed18b1a1a6e64352086006f9e"
  }
}

Select multiple blocks

Select multiple blocks by either numbers: [int] or hashes: [string].

{
  blocks(hashes: ["0x624d6c50f4edff05693806953b211050ef3e674ed18b1a1a6e64352086006f9e",
      "0xbfe0f792a89bd44e6c22224a84721edfedb334e521afb365fd397442bc1b2b81",
      "0x0cd6b3ef09f74b86fd8e17122deae11c1016a578797472bee1a3bb138323954b"]) {
    number
  }
}

The example query above returns the following:

{
  blocks: [
    { number: 1234 } 
    { number: 1235 }
    { number: 12342 }
  ]
}

Select a range of blocks

Select a range of blocks by either numberRange: [int, int] or hashRange: [string, string].

{
  blocksRange(numberRange: [10, 12]) {
    timestamp
  }
}

The example query above returns the following:

{ 
  blocksRange: [
    { timestamp: "1438270128" } 
    { timestamp: "1438270136" }
    { timestamp: "1438270144" }
  ] 
}

Select an account

Select an account by address: string.

{
  account(address: "0x0000000000000000000000000000000000000000") {
    transactionCount
  }
}

The example query above returns the following:

{
  account: {
    transactionCount: 0
  }
}

Select a transaction

Select a transaction by hash: string.

{
  transaction(hash: "0xdccbeb289f6630fd76fa2681837422fda9f76449653aa750d4e6b2822cf300fd") {
    nonce
  }
}

The example query above returns the following:

{
  transaction: { 
    nonce: 10
  }
}

Check server health

Check if the server is healthy.

{
  health
}

The example query above returns the following:

{ 
  health: ok
}