# getBlock
Solana API method that returns the identity and transaction information about a confirmed block in the ledger.
Parameters:
block_id
— the slot, asu64
integer.object
— optional configuration fields:encoding: <string>
— (optional) the encoding for each returned transaction, eitherjson
,jsonParsed
,base58
(slow),base64
. If the parameter is not provided, the default encoding isjson
.jsonParsed
encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the transaction.message.instructions list. IfjsonParsed
is requested, but a parser cannot be found, the instruction falls back to standard JSON encoding (accounts, data, and programIdIndex fields).transactionDetails: <string>
— (optional) the level of transaction detail to return, eitherfull
,accounts
,signatures
, ornone
. The default detail level isfull
if the parameter is not provided. Ifaccounts
are requested, transaction details only include signatures and an annotated list of accounts in each transaction. Transaction metadata is limited tofee
,err
,pre_balances
,post_balances
,pre_token_balances
, andpost_token_balances
.rewards: bool
— (optional) whether to populate the rewards array. If a parameter is not provided, the default includes rewards.commitment: <string>
— (optional) the commitment;processed
is not supported. If the parameter is not provided, the default isfinalized
.maxSupportedTransactionVersion: <number>
— (optional) set the max transaction version to return in responses. If the requested block contains a transaction with a higher version, an error will be returned. Only legacy transactions will be returned if this parameter is omitted, and a block containing any versioned transaction will prompt the error.
Returns:
The result will be an RPC response JSON object with value
equal to one of the following:
<null>
— if the specified block is not confirmed.<object>
— an object containing:blockhash: <string>
— the blockhash of this block, as a base58 encoded string.previousBlockhash: <string>
— the blockhash of this block's parent, as a base58 encoded string; if the parent block is not available due to ledger cleanup, this field will return11111111111111111111111111111111
.parentSlot: <u64>
— the slot index of this block's parent.transactions: <array>
— present iffull
transaction details are requested.
Example:
- Solana web3.js
- Solana.py
- cURL
import { Connection } from "@solana/web3.js";
const nodeUrl = "CHAINSTACK_NODE_URL"
const connect = new Connection(nodeUrl);
(async () => {
console.log(await connect.getBlock(151548100));
})();