getBlock - Solana

This method returns identity and transaction information for a confirmed block at a given slot. Response size can be reduced with the transactionDetails and rewards options.

Parameters

ParameterTypeRequiredDescription
slotnumberYesSlot number of the block to fetch
configobjectNoConfiguration object controlling encoding and detail level

Config Object

FieldTypeRequiredDescription
encodingstringNoTransaction encoding: json, jsonParsed, base58, or base64
transactionDetailsstringNoLevel of detail: full, accounts, signatures, or none
rewardsbooleanNoInclude the block rewards array. Defaults to true
commitmentstringNoCommitment level: confirmed or finalized. The processed level is not supported
maxSupportedTransactionVersionnumberNoHighest transaction version the client can decode. Set to 1: a request capped at 0 fails with -32015 on a v1 transaction

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getBlock",
    "params": [397234561, {"encoding": "jsonParsed", "transactionDetails": "signatures", "rewards": false, "maxSupportedTransactionVersion": 1}],
    "id": "getblock.io"
}'

example.js

javascriptconst { Connection } = require('@solana/web3.js');

const connection = new Connection('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', 'confirmed');

const block = await connection.getBlock(397234561, {
  transactionDetails: 'signatures',
  rewards: false,
  maxSupportedTransactionVersion: 1
});

console.log(block?.blockhash, block?.signatures?.length);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'getBlock',
        'params': [397234561, {"encoding": "jsonParsed", "transactionDetails": "signatures", "rewards": false, "maxSupportedTransactionVersion": 1}],
        'id': 'getblock.io'
    }
)

print(response.json()['result'])

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "getBlock",
            "params": [397234561, {"encoding": "jsonParsed", "transactionDetails": "signatures", "rewards": false, "maxSupportedTransactionVersion": 1}],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;

    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "blockHeight": 375812409,
        "blockTime": 1774267845,
        "blockhash": "9zJqLXK9pMhQZ4tGqVvUcxrKpKQ3pMSJ1nZmVeXtBqTd",
        "parentSlot": 397234560,
        "previousBlockhash": "8pQnEuNy2FTWSpMB1mQ2VtxYbFPqYWDVWtEZ4XKtx6Bs",
        "signatures": [
            "5wHu1qwD4kLwYqPmy1uDCgpiJ1qGpVYU3n5aHT6bSWUE1JzcbQCPSDLDPGrFyqmLLzQjLNPTPtRZbNbUJQNMkaWq"
        ]
    }
}

Response Parameters

ParameterTypeDescription
jsonrpcstringJSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
resultobjectnull

Result Object

FieldTypeDescription
blockhashstringBase58-encoded blockhash of this block
previousBlockhashstringBase58-encoded blockhash of the parent block
parentSlotnumberSlot of the parent block
blockHeightnumbernull
blockTimenumbernull
transactionsarrayTransaction objects, present when transactionDetails is full or accounts
signaturesarraySignature strings, present when transactionDetails is signatures
rewardsarrayReward entries, present when rewards is true

Use Cases

  • Block Explorers: Render block contents including transactions and rewards
  • Indexer Pipelines: Stream blocks sequentially to build an off-chain database
  • Validator Rewards: Read the rewards array to attribute fees and staking payouts
  • Throughput Analysis: Count transactions per block to measure real network load
  • Reorg-Safe Reads: Request finalized commitment when block data must not change

Error Handling

Error CodeMessageDescription
-32007Slot was skipped, or missing due to ledger jump to recent snapshotThe slot was skipped by the leader or predates the node's snapshot
-32009Slot was skipped, or missing in long-term storageThe slot is absent from the node's long-term ledger storage
-32602Invalid paramsSlot is negative or an unsupported transactionDetails value was supplied
-32015Transaction version (1) is not supported by the requesting clientmaxSupportedTransactionVersion was omitted or is lower than the version of a transaction in the block
-32004Block not available for slotThe node has not yet produced or received the block