For the complete documentation index, see llms.txt. This page is also available as Markdown.

getBlock - Solana

Example code for the getBlock JSON-RPC method. Complete guide on how to use getBlock JSON-RPC in GetBlock Web3 documentation.

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

Parameter
Type
Required
Description

slot

number

Yes

Slot number of the block to fetch

config

object

No

Configuration object controlling encoding and detail level

Config Object

Field
Type
Required
Description

encoding

string

No

Transaction encoding: json, jsonParsed, base58, or base64

transactionDetails

string

No

Level of detail: full, accounts, signatures, or none

rewards

boolean

No

Include the block rewards array. Defaults to true

commitment

string

No

Commitment level: confirmed or finalized. The processed level is not supported

maxSupportedTransactionVersion

number

No

Highest transaction version the client can decode. Set to 0 for versioned transactions

Request

curl --location --request POST 'https://go.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": 0}],
    "id": "getblock.io"
}'
example.js
const { Connection } = require('@solana/web3.js');

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

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

console.log(block?.blockhash, block?.signatures?.length);
example.py
import requests

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

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

Response

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

object

null

Result Object

Field
Type
Description

blockhash

string

Base58-encoded blockhash of this block

previousBlockhash

string

Base58-encoded blockhash of the parent block

parentSlot

number

Slot of the parent block

blockHeight

number

null

blockTime

number

null

transactions

array

Transaction objects, present when transactionDetails is full or accounts

signatures

array

Signature strings, present when transactionDetails is signatures

rewards

array

Reward 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 Code
Message
Description

-32007

Slot was skipped, or missing due to ledger jump to recent snapshot

The slot was skipped by the leader or predates the node's snapshot

-32009

Slot was skipped, or missing in long-term storage

The slot is absent from the node's long-term ledger storage

-32602

Invalid params

Slot is negative or an unsupported transactionDetails value was supplied

-32015

Transaction version (0) is not supported by the requesting client

maxSupportedTransactionVersion was omitted for a block containing versioned transactions

-32004

Block not available for slot

The node has not yet produced or received the block

Last updated

Was this helpful?