getBlock
Learn getBlock use cases, code examples, request parameters, response structure, and tips. Ask ChatGPT
The getBlock RPC method allows you to retrieve detailed information about a confirmed block in the Solana ledger. This is essential for block explorers, transaction history analysis, and understanding the state of the chain at a specific point in time.
Common Use Cases
Inspecting Block Contents View all transactions included in a specific block.
Retrieving Block Hashes Get the blockhash for a given slot, its parent’s blockhash, and its parent slot.
Checking Block Height and Time Find out a block’s height (its sequence number) and its estimated production time.
Analyzing Transaction Details With appropriate parameters, retrieve full transaction data, including metadata like fees, status, pre/post balances, and inner instructions.
Fetching Rewards Optionally include reward information for the block.
Parameters
slot(number, required): The slot number of the block to query (u64).config(object, optional): Configuration options include:commitment(string): Commitment level.processedis not supported. Defaults tofinalized.encoding(string): How transaction data is returned. Defaults tojsoniftransactionDetailsisfulloraccounts, otherwisebase64. Options:json(deprecated)jsonParsed(recommended for parsed keys and Lookup Table support)base58base64base64+zstd
transactionDetails(string): Level of transaction detail to return. Defaults tofull.fullaccountssignaturesnone
rewards(boolean): Include rewards array iftrue. Defaults tofalse.maxSupportedTransactionVersion(number): Maximum transaction version to return. Set to0to include versioned transactions using Address Lookup Tables.
Response
If the block is found and confirmed, the result will include:
blockhash(string): The base-58 encoded blockhash.previousBlockhash(string): The base-58 encoded blockhash of the previous block.parentSlot(number): The slot number of the parent block.transactions(array): List of transactions included in the block. Each entry contains:meta: Transaction metadata (e.g., fee, logs, balances).transaction: The raw transaction data, including signatures and message content.
rewards(array, optional): Present ifrewards: truewas requested. Includes reward info (e.g.,pubkey,lamports,postBalance,rewardType, andcommission).blockTime(number | null): Estimated Unix timestamp of block production.blockHeight(number | null): Sequence number from genesis slot.
If the block is not found or unconfirmed, result will be null.
Example: Fetching Block Information
Here’s how to retrieve block info for a sample slot (e.g., 355184627) on Devnet. Replace it with a current confirmed slot number for accurate results.
Also, replace X-API-KEY with your actual CoinVera API key.
Example Response
Developer Tips
Slot vs. Block Height The
getBlockmethod accepts a slot number, not a block height. While slots are generally sequential, some may be skipped by the validator leader. To get the actual block sequence number, refer to theblockHeightfield in the response.maxSupportedTransactionVersionIs Crucial To retrieve blocks containing versioned transactions (now standard and using Address Lookup Tables), you must specify:"maxSupportedTransactionVersion": 0Omitting this may lead to errors when querying modern blocks.Choosing
transactionDetailsLevel:full: For comprehensive analysis—returns the most complete data including metadata.signatures: Best for listing only transaction signatures in a block.accounts: A good middle ground—lists involved accounts without full instructions.none: Use when you only need high-level block metadata likeblockhashorrewards.
Use
jsonParsedfor Encoding When requesting transaction details,jsonParsedis the recommended format. It provides a structured, human-readable JSON output and supports address resolution from Lookup Tables. Avoid usingjson(deprecated), as it lacks modern feature support.Block Unavailability Handling A
nullresponse can mean:The slot was skipped.
The block hasn’t reached the requested commitment level.
The RPC node (e.g., CoinVera) has pruned the block due to ledger limits—common with older historical data.
Include Rewards When Needed To retrieve block reward distribution info (e.g., for validators and stakers), set:
"rewards": trueThis increases response size but is essential for full reward visibility.
Last updated