Querying blocks
A worked example of pulling a block and its transactions from Chaingraph.
Query
query LatestBlock {
block(limit: 1, order_by: { height: desc }) {
hash
height
timestamp
transaction_count
size_bytes
transactions(limit: 5) {
hash
size_bytes
input_count
output_count
}
}
}
Send
curl https://solidpeer.io/chaingraph/mainnet/<token> \
-H "content-type: application/json" \
-d '{"query":"query LatestBlock { block(limit:1, order_by:{height:desc}) { hash height timestamp transaction_count size_bytes transactions(limit:5) { hash size_bytes input_count output_count } } }"}'
Response shape
{
"data": {
"block": [
{
"hash": "00000000...",
"height": 882357,
"timestamp": 1715300000,
"transaction_count": 64,
"size_bytes": 51842,
"transactions": [
{ "hash": "abc...", "size_bytes": 226, "input_count": 1, "output_count": 2 },
...
]
}
]
}
}
Filtering
Every list-shaped root field accepts a where: argument. Some examples:
# Blocks in a height range
block(where: { height: { _gte: 800000, _lte: 800100 } }) { hash height }
# Blocks at-or-after a wall-clock timestamp
block(where: { timestamp: { _gte: 1709000000 } }) { hash height timestamp }
# A specific block by hash (singleton form)
block_by_pk(hash: "<64-hex>") { height timestamp transaction_count }
Pagination
Use limit: + offset: for naive pagination, or cursor-style by carrying the last-seen height in subsequent where: filters. Cursor-style is faster on deep pagination — Hasura's offset does a sequential scan past skipped rows.
Cost
Computed from query complexity (depth × per-field weight × multiplier). The audit-log entry for each call shows the score; per-cycle usage in the dashboard rolls it up. Mainnet base cost is 300 CC; the score scales with how much work the query asks Hasura / Postgres to do.
If a customer's query exceeds their account balance mid-execution, the gateway returns 429 balance before the response is delivered.