-
Notifications
You must be signed in to change notification settings - Fork 85
Top Level Queries
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 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 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 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 by address: string
.
{
account(address: "0x0000000000000000000000000000000000000000") {
transactionCount
}
}
The example query above returns the following:
{
account: {
transactionCount: 0
}
}
Select a transaction by hash: string
.
{
transaction(hash: "0xdccbeb289f6630fd76fa2681837422fda9f76449653aa750d4e6b2822cf300fd") {
nonce
}
}
The example query above returns the following:
{
transaction: {
nonce: 10
}
}
Check if the server is healthy.
{
health
}
The example query above returns the following:
{
health: ok
}
- Top-Level Queries
- Example Use Cases
- Block Query Fields
- Account Query Fields
- Transaction Query Fields
- Log Query Fields
- Decoded Transaction Query Fields
- ENS plugin: resolving names into addresses