getBlock
Returns the identity and transaction information for a confirmed block in the ledger. This method is essential for block explorers, indexers, and analytics services that need to inspect the complete contents of a specific slot. It returns transaction details, rewards, and block metadata including the blockhash, parent slot, and block time.
Parameters
| # | Type | Required | Description |
|---|---|---|---|
| 1 | u64 | Yes | Slot number of the block to retrieve, as a u64 integer |
| 2 | object | No | Configuration object |
Configuration object fields:
| Field | Type | Description |
|---|---|---|
commitment | string | Commitment level: processed, confirmed, or finalized (default finalized) |
encoding | string | Transaction encoding: json, jsonParsed, base58, or base64 (default json) |
transactionDetails | string | Detail level: full, accounts, signatures, or none (default full) |
maxSupportedTransactionVersion | number | Max transaction version to return. If omitted, only legacy transactions are returned |
rewards | bool | Whether to populate the rewards array (default true) |
Response
Returns null if the block is not available. Otherwise returns an object:
| Field | Type | Description |
|---|---|---|
blockhash | string | The blockhash of this block (base-58) |
previousBlockhash | string | The blockhash of the parent block |
parentSlot | u64 | The slot index of the parent block |
transactions | array | Array of transaction objects if transactionDetails is not none |
rewards | array | Array of reward objects if rewards is true |
blockTime | `i64 | null` |
blockHeight | `u64 | null` |
Code Examples
cURL
curl http://88.216.36.108:7999 -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlock",
"params": [
166974442,
{
"encoding": "jsonParsed",
"maxSupportedTransactionVersion": 0,
"transactionDetails": "full",
"rewards": false
}
]
}'TypeScript
const response = await fetch("http://88.216.36.108:7999", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getBlock",
params: [
166974442,
{
encoding: "jsonParsed",
maxSupportedTransactionVersion: 0,
transactionDetails: "full",
rewards: false
}
]
}),
});
const { result } = await response.json();
console.log("Block hash:", result.blockhash);Python
import requests
response = requests.post("http://88.216.36.108:7999", json={
"jsonrpc": "2.0",
"id": 1,
"method": "getBlock",
"params": [
166974442,
{
"encoding": "jsonParsed",
"maxSupportedTransactionVersion": 0,
"transactionDetails": "full",
"rewards": False
}
]
})
result = response.json()["result"]
print(f"Block hash: {result['blockhash']}")Rust
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client.post("http://88.216.36.108:7999")
.json(&json!({
"jsonrpc": "2.0",
"id": 1,
"method": "getBlock",
"params": [
166974442_u64,
{"encoding": "jsonParsed", "maxSupportedTransactionVersion": 0, "transactionDetails": "full", "rewards": false}
]
}))
.send().await?
.text().await?;
println!("{}", res);
Ok(())
}Example Response
{
"jsonrpc": "2.0",
"result": {
"blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA",
"previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B",
"parentSlot": 166974441,
"transactions": [],
"blockTime": 1681391935,
"blockHeight": 150676031
},
"id": 1
}