Skip to main content

getLatestBlockhash

Returns the latest block hash.

Parameters

  • config: (object) [optional] - Configuration object with the following options:
    • commitment: (string) [optional] - The commitment level to use for the query. The default is finalized. Possible values are:
      • finalized - Queries the most recent block confirmed by a super majority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.
      • confirmed - Queries the most recent block that has been voted on by a super majority of the cluster.
      • processed - Queries its most recent block. The block may still be skipped by the cluster.
    • minContextSlot: [optional] - The minimum slot to use for the query.

Returns

result - An object with the following fields:

  • context - An object containing the following keys:
    • slot - The slot number of the block that was queried.
    • apiVersion - The API version used for the query.
  • value - An object containing the following keys:
    • blockhash - The base58 encoded block hash.
    • lastValidBlockHeight - The last block height at which the block hash will be valid.

Request

curl https://solana-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1, "method": "getLatestBlockhash", "params": []}'

Response

{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.3",
"slot": 372758352
},
"value": {
"blockhash": "4zuGA4EyEjaN25qMVnwwij4UMRWcmEpFn1txrzMMk5xw",
"lastValidBlockHeight": 360735720
}
},
"id": 1
}