getBlock
All the specifications for getBlock RPC Method on Solana
Returns identity and transaction information about a confirmed block in the ledger
Parameters required for this RPC call
The slot number for which the corresponding block will be returned. This is a u64 number.
configuration : This contains the following parameters, all are optional fields.
commitment: The commitment describes how finalized a block is at that point in time. Only confirmed and finalized are supported, defaults to finalized.
encoding: Encoding format for each returned transaction. The supported options are json, jsonParsed, base58 and base64. You can know more about Parsed responses more on Solana docs.
transactionDetails: Specifies the level of transaction detail to return.
If
accountsare requested, transaction details only include signatures and an annotated list of accounts in each transaction.Transaction metadata is limited to only: fee, err, pre_balances, post_balances, pre_token_balances, and post_token_balances.
Supports the following values: full, accounts, signatures or none. Defaults to full.
curl https://rpc.shyft.to?api_key=YOUR-API-KEY -s -X \
POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlock",
"params": [
378967388,
{
"commitment": "finalized",
"encoding": "json",
"transactionDetails": "full",
"maxSupportedTransactionVersion": 0,
"rewards": false
}
]
}
'import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection("https://rpc.shyft.to?api_key=YOUR-API-KEY", "confirmed");
const slot_number = 377261141;
const block = await connection.getBlock(
slot_number,
{
commitment: "finalized",
transactionDetails: "full",
maxSupportedTransactionVersion: 0,
rewards: false,
},
);
console.log("block:", block);Last updated
Was this helpful?