GraphQL - HashKey Chain

HashKey Chain exposes an EIP-1767 GraphQL API: a single /graphql endpoint that lets you request exactly the block, transaction, account, and log fields you need — with nesting — in one query, plus a mutation to broadcast transactions. It complements the JSON-RPC and WebSocket interfaces, and is useful when a single round-trip should return a precisely-shaped slice of chain data.

Endpoint

GraphQL is served over HTTP POST at the endpoint base URL with graphql appended.

bashexport HSK_GQL=https://shared.us-east-1.getblock.io/<ACCESS-TOKEN>/

# POST a GraphQL query to the /graphql path
curl -X POST "${HSK_GQL}graphql" \
  -H "Content-Type: application/json" \
  -d '{"query":"{ block { number hash timestamp gasUsed } }"}'

Replace <ACCESS-TOKEN> with the access token from the GetBlock dashboard. HashKey Chain is served from the New York region; GraphQL shares the same base URL as JSON-RPC, with graphql appended.

Operations

OperationTypeDescription
blockqueryFetch a block by number or hash
blocksqueryFetch a range of blocks (from / to)
transactionqueryFetch a transaction by hash
accountqueryRead an account's balance, nonce, code, and storage at a block
callqueryExecute a read-only contract call
estimateGasqueryEstimate gas for a call
logsqueryQuery event logs by filter (addresses, topics, block range)
gasPricequeryCurrent gas price
sendRawTransactionmutationBroadcast a signed raw transaction

Example Queries

Block with its transactions

graphql{
  block(number: 5000000) {
    number
    hash
    timestamp
    gasUsed
    gasLimit
    transactions {
      hash
      from { address }
      to { address }
      value
    }
  }
}

Account balance and nonce

graphql{
  account(address: "0x177b1a2c3d4e5f60718293a4b5c6d7e8f90a1b2c") {
    balance
    transactionCount
    code
  }
}

Logs by filter

graphql{
  logs(filter: {
    fromBlock: 5000000,
    toBlock: 5000100,
    addresses: ["0x177b1a2c3d4e5f60718293a4b5c6d7e8f90a1b2c"]
  }) {
    index
    topics
    data
    transaction { hash }
  }
}

Read-only contract call

graphql{
  call(data: {
    to: "0x177b1a2c3d4e5f60718293a4b5c6d7e8f90a1b2c",
    data: "0x18160ddd"
  }) {
    data
    status
    gasUsed
  }
}

Broadcast a transaction (mutation)

graphqlmutation {
  sendRawTransaction(data: "0x02f8...signed-tx-hex")
}

Response

A GraphQL response wraps the requested shape under a top-level data key:

json{
    "data": {
        "block": {
            "number": 5000000,
            "hash": "0x9a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "timestamp": "0x66a1b2c3",
            "gasUsed": "0x5208"
        }
    }
}

Response Fields

FieldTypeDescription
dataobjectThe result, shaped exactly like the query
errorsarrayPresent only on failure; each entry has a message and the query path

Use Cases

  • Precise fetching: Request only the block, transaction, or account fields you need, nested in one round-trip
  • Explorer backends: Pull a block with its transactions and logs in a single query
  • Batch reads: Fetch a range of blocks (blocks(from, to)) without many JSON-RPC calls
  • Broadcast: Submit a signed transaction with the sendRawTransaction mutation

Error Handling

ErrorMessageDescription
400 / Bad requestSyntax / validation errorThe GraphQL query was malformed or referenced unknown fields (see errors)
200 with errorsField resolution errorThe query parsed but a field could not be resolved (e.g. block not found)
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect

See Also