AptosAptos Network's breakthrough technology and seamless user experience are now available on QuickNode.

Start building today!     

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:

  1. slot - integer - The slot number of the block to retrieve encoded as u64 (64-bit unsigned integer) integer
  2. object - (optional) The configuration object with the following fields:

    encoding - string - (optional) The encoding format for account data. It can be one of base58 (slow), base64, base64+zstd or jsonParsed

    transactionDetails - string - (optional) (default:full) The level of transaction detail to return. It could be full, accounts, signatures, or none

    rewards - boolean - (optional) (default:false) A boolean flag that indicates whether to include reward information in the block response

    Commitment - string - (optional) The level of commitment required for the query. The options include:

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

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

    Processed - string - It is not supported for this method

    maxSupportedTransactionVersion - boolean - (optional) The maximum 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 - boolean - (optional) The older transaction format with no additional benefit

    0 - boolean - (optional) The additional support for Address Lookup Tables

  3. Returns:

    1. result - Null if the specified block is not confirmed otherwise RpcResponse JSON object with the following fields:

      blockHeight - The number of blocks beneath this block

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

      blockhash - The hash of the block encoded as base-58 string

      parentSlot - The slot index of this block's parent

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

      transactions - It is present if full transaction details are requested; an array of JSON objects with the following fields:

      meta - The transaction status metadata object, which contains additional information about the block and its transactions. The meta object can be null, or it may contain the following fields:

      err - Error code if the transaction failed or null if the transaction succeeds

      fee - The total fees paid by all transactions in the block encoded as u64 integer

      innerInstructions - An array of objects representing the inner instructions of all transactions in the block (omitted if inner instruction recording is not enabled). Each object has the following fields:

      logMessages - An array of strings containing any log messages generated by the block's transactions (omitted if inner instruction recording is not enabled)

      postBalances - An array of lamport balances for each account in the block after the transactions were processed

      postTokenBalances - An array of token balances for each token account in the block after the transactions were processed (omitted if inner instruction recording is not enabled)

      preBalances - An array of lamport balances for each account in the block before the transactions were processed

      preTokenBalances - An array of token balances for each token account in the block before the transactions were processed (omitted if inner instruction recording is not enabled)

      rewards - An object containing information about the rewards earned by the block's validators (only present if the rewards are requested). It has the following fields:

      pubkey - The public key of the account that received the award encoded as base-58 string

      lamports - The number of reward lamports credited or debited by the account

      postBalance - The account balance in lamports after the reward was applied

      rewardType - The type of reward. It could be fee, rent, voting, staking

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

      status - The status of the transaction. It returns Ok if the transaction was successful and Err if the transaction failed with TransactionError

      transaction - The transaction object. It could be either JSON format or encoded binary data, depending on the encoding parameter

      message - An array of transactions included in the block

      accountKeys - An array of public keys associated with the accounts that were accessed during the execution of transactions in the block

      pubkey - The public key associated with the block producer who created the block

      signer - It is used to sign transactions in the block. It can also be used to identify the signers involved in the block's transactions and to verify the authenticity of the signatures

      source - It is used to identify the accounts that provided the funds for the block's transactions

      writable - A boolean value that indicates whether the accounts associated with the given public keys were modified by the transactions or not

      addressTableLookups - An array of address lookups that were performed during the execution of transactions in the block

      instructions - An array of instructions that were executed in the block's transactions

      parsed - An array of parsed instructions that were executed in the block's transactions

      info - An array of information objects that provide additional details about the transactions in the block

      clockSysvar - It provides information about the current state of the Solana blockchain

      slotHashesSysvar - It provides information about the hashes of recent slots

      vote - An array of vote accounts that were involved in the block's transactions

      hash - The hash of the block. It can be used to uniquely identify the block and to verify the authenticity of the block's contents

      slots - An array of slot numbers that correspond to the transactions in the block

      timestamp - The Unix timestamp of the block's creation

      voteAccount - A vote account to identify the validator who produced the block and to verify the validity of their vote

      voteAuthority - An authority associated with the vote account used to produce the block

      type - The type of the block. It can be used to differentiate between regular blocks and special blocks such as snapshot or transaction confirmation blocks

      program - The data associated with the program that was executed in the block's transactions

      programId - The public key of the program that was executed in the block's transactions

      recentBlockhash - The recent block hash for the account's cluster

      signatures - The list of transaction signatures contained within a particular block

      version - The transaction version. It's undefined if maxSupportedTransactionVersion is not set in the requested parameters

Code Examples:

from solana.rpc.api import Client
solana_client = Client("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/")
print(solana_client.get_block(94101948, "jsonParsed", max_supported_transaction_version=0))
Ready to get started? Create a free account