GraphQL API

GraphQL on Tetreum Testnet

What is GraphQL

GraphQL is a query language for APIs that allows clients to request exactly the data they need. It provides a flexible and efficient way to access blockchain data without over-fetching unnecessary fields.

Key concepts of GraphQL:

  • Hierarchical

  • Strongly typed

  • Client-specified queries

Advantages of GraphQL:

  • Declarative data fetching

  • Flexible response structure

  • Efficient client integration

  • Easier exploration of blockchain data

Query Types

There are three main GraphQL operation types:

1

Query

Used to fetch data.

query {
  block(number: 1) {
    hash
    number
  }
}
2

Mutation

Used to change data.

mutation {
  exampleMutation(id: 1) {
    id
  }
}
3

Subscription

Used to subscribe to real-time updates.

subscription {
  newTransaction {
    hash
    blockNumber
  }
}

Access GraphQL API

You can access the Tetreum Testnet GraphQL API from the explorer interface or by using your preferred HTTP client.

GraphQL Endpoint

Explorer

You can test queries from the explorer's API section if GraphQL is enabled on the instance.

You can also use curl:

Queries

The Tetreum Testnet GraphQL API can be used to query blockchain data such as addresses, blocks, and transactions.

Common Queries

Query
Description
Example

address(hash: AddressHash!)

Get an address by hash

{ address(hash: "0x...") { hash } }

addresses(hashes: [AddressHash!])

Get multiple addresses by hash

{ addresses(hashes: ["0x...", "0x..."]) { hash } }

block(number: Int!)

Get a block by number

{ block(number: 1) { hash number } }

transaction(hash: FullHash!)

Get a transaction by hash

{ transaction(hash: "0x...") { hash gasUsed } }

Example Query

Example query to retrieve transactions for a specific address:

Transaction lists may support pagination arguments such as:

  • first

  • after

  • before

Notes

  • GraphQL availability depends on the explorer configuration

  • Tetreum Testnet is a Geth-based PoA network

  • The GraphQL API is intended for development, analytics, and explorer-based queries

  • For standard wallet and dApp interactions, use the JSON-RPC endpoint

RPC URL

Chain ID

Currency Symbol

Last updated