block
API Context — Endpoint: https://api.onesource.io/federation/{'{'}chain{'}'}/graphql | Auth Header: x-bp-token: BP-{YOUR_API_KEY} | Method: POST | Content-Type: application/json
Look up a block by number or hash.
Provide either number or hash, not both. Returns null if the block doesn't exist.
Schema Definition
block(
number: BlockNumber
hash: BlockHash
): Block
Arguments
| Argument | Type | Description |
|---|---|---|
number | BlockNumber scalar | Block number (height) to look up. |
hash | BlockHash scalar | Block hash to look up. |
Return Type
| Type | Description |
|---|---|
Block object | A block containing transactions and metadata. Blocks are the fundamental unit of the blockchain, each building on the previous one. |
Common Use Cases
- Display detailed block information in block explorer applications.
- Verify that a specific transaction was included in a block and retrieve its confirmation count for payment validation.
- Analyze gas usage patterns across blocks to help users optimize their transaction timing and gas price strategies.
- Monitor blocks for specific criteria such as high gas usage, large transaction volumes, or particular transaction patterns.
- List contracts deployed within a specific block using the nested
contractsCreatedfield.
Example
Query
Identify Wrapped Ether (WETH) Transactions in a Specific Block
query WrappedEtherBlockTransactions(
$number: BlockNumber
$first: Int
$where: BlockTransactionFilter
) {
block(number: $number) {
number
hash
timestamp
transactionCount
size
gasUsed
gasLimit
confirmations
transactions(first: $first, where: $where) {
totalCount
pageInfo {
hasNextPage
endCursor
}
entries {
hash
from {
address
}
to {
address
}
value {
raw
formatted
}
gas {
limit
price
used
}
timestamp
status
}
}
}
}
Variables
{
"number": 22530116,
"first": 5,
"where": {
"to": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
}
}
Response
{
"data": {
"block": {
"number": 22530116,
"hash": "0x968ae3cd572c782192b122d7d579672e0237aee0d644a90b591d4f5b7f745b95",
"timestamp": "2025-09-14T18:22:35Z",
"transactionCount": 312,
"size": 170635,
"gasUsed": "35980169",
"gasLimit": "36000000",
"confirmations": 1149727,
"transactions": {
"totalCount": 8,
"pageInfo": {
"hasNextPage": true,
"endCursor": "eyJpZCI6NX0="
},
"entries": [
{
"hash": "0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060",
"from": {
"address": "0x32f5ae3af145dbd51f5a84b0004b7588a87c9790"
},
"to": {
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
},
"value": {
"raw": "1000000000000000000",
"formatted": "1.0"
},
"gas": {
"limit": 54244,
"price": "1250655772",
"used": 46109
},
"timestamp": "2025-09-14T18:22:35Z",
"status": "SUCCESS"
}
]
}
}
}
}
Implementation Notes
note
- The
blockquery returnsnullif the block doesn't exist. Always handle the null case in your application. - Provide either
numberorhashto look up a block, not both. Thenumberargument is of typeBlockNumber(a positive integer representing block height). Thehashargument is of typeBlockHash(a0x-prefixed, 66-character hex string). - Using
numberto query by block height is generally most efficient and the most common approach. Usehashwhen you have a specific block hash from a transaction receipt or block header. - The
gasUsedandgasLimitfields areBigIntstrings (not integers), since gas values can exceed JavaScript's safe integer range. - The
timestampfield returns an ISO 8601 formatted string (e.g.,"2025-09-14T18:22:35Z"), not a Unix integer. - The
confirmationsfield updates dynamically as new blocks are mined. Higher confirmation counts indicate lower risk of chain reorganization. - The nested
transactionsfield returns aBlockTransactionListand accepts its own pagination arguments (first,after) and filter/sort arguments. The filter type isBlockTransactionFilter(notTransactionFilter), which supports filtering byfrom,to,value,gasPrice,gasUsed, andstatus. - Transactions within a block are returned as
BlockTransactionobjects — a lighter-weight representation than the fullTransactiontype. Fields likefromandtoreturnAddressobjects (usefrom { address }to get the hex string),valuereturns aTokenAmountobject, andgasreturns aGasInfoobject. - The nested
contractsCreatedfield returns aContractListof contracts deployed in that block, with its own pagination and filter/sort arguments usingContractFilterandContractOrderBy. - To search and filter across multiple blocks, use the
blocksquery with pagination and filtering support.