Marketplace has launched, further enabling blockchain developers! Learn more

Contents

getBlock RPC method

The API credit value for this method is 7 . To learn more about API credits and each method's value, visit the API Credits page.

Though getBlock is supported, Solana Foundation recommends using jsonParsed encoding because it includes all transaction account keys (including those from Lookup Tables). To do this with JavaScript, please refer to the getParsedBlock RPC method.

Parameters:

slot_number - slot, as u64 (64-bit unsigned integer) integer.

Object - (optional) Configuration object containing the following optional fields:

encoding - (optional) encoding for each returned Transaction, either "json", "jsonParsed", "base58" (slow), "base64". If parameter not provided, the default encoding is "json".

transactionDetails - (optional) level of transaction detail to return, either "full", "signatures", or "none". If parameter not provided, the default detail level is "full".

rewards - (optional) Boolean value, whether to populate the rewards array. If parameter not provided, the default includes rewards.

Commitment - (optional) "processed" is not supported. If parameter not provided, the default is "finalized".

Finalized - the node will query the most recent block confirmed by supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.

Confirmed - the node will query the most recent block that has been voted on by supermajority of the cluster.

Processed - not supported in this method.

maxSupportedTransactionVersion (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. If this parameter is omitted, only legacy transactions will be returned, and a block containing any versioned transaction will prompt an error.

legacy - older transaction format with no additional benefit (default value).

0 - added support for Address Lookup Tables.

Returns:

Result - The result field will be an object with the following fields:

null - if specified block is not confirmed.

Object - if block is confirmed, an object with the following fields:

blockhash - the blockhash of this block, as base-58 encoded string.

previousBlockhash - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111".

parentSlot - the slot index of this block's parent.

transactions - present if "full" transaction details are requested; an array of JSON objects containing:

transaction - Transaction object, either in JSON format or encoded binary data, depending on encoding parameter.

meta - transaction status metadata object, containing null or:

err - Error if transaction failed, null if transaction succeeded.

fee - fee this transaction was charged, as u64 integer.

preBalances - array of u64 account balances from before the transaction was processed.

postBalances - array of u64 account balances after the transaction was processed.

innerInstructions - List of inner instructions or omitted if inner instruction recording was not yet enabled during this transaction.

preTokenBalances - List of token balances from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction.

postTokenBalances - List of token balances from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction.

logMessages - array of string log messages or omitted if log message recording was not yet enabled during this transaction.

loadedAddresses - Transaction addresses loaded from address lookup tables. Undefined if maxSupportedTransactionVersion is not set in request params.

writable - Ordered list of base-58 encoded addresses for writable loaded accounts.

readonly - Ordered list of base-58 encoded addresses for readonly loaded accounts.

version - Transaction version. Undefined if maxSupportedTransactionVersion is not set in request params.

signatures - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block.

rewards - present if rewards are requested; an array of JSON objects containing:

pubkey - The public key, as base-58 encoded string, of the account that received the reward.

lamports - Number of reward lamports credited or debited by the account, as an i64.

postBalance - Account balance in lamports after the reward was applied

rewardType - Type of reward: currently only "rent", other types may be added in the future

comission - Vote account commission when the reward was credited, only present for voting and staking rewards

blockTime - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available.

blockHeight - the number of blocks beneath this block.

Code Examples:

const web3 = require("@solana/web3.js");
(async () => {
  const solana = new web3.Connection("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/");
  console.log(
    await solana.getBlock(94101948, { maxSupportedTransactionVersion: 0 })
  );
})();
Ready to get started? Create a free account