---
title: getLatestBlockhash
description: >-
  Returns the latest recent blockhash and its last valid block height.
url: /docs/rpc/http/getlatestblockhash
type: reference
hideTableOfContents: true
---

Returns the latest recent blockhash and its last valid block height.

<Callout type="info" title="Source">
  [`get_latest_blockhash`](https://github.com/anza-xyz/agave/blob/v3.1.8/rpc/src/rpc.rs#L2352)
</Callout>

<APIMethod>

```jsonc !!request curl
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getLatestBlockhash",
  "params": [
    // !hover(1:3) config
    {
      // !hover commitment
      "commitment": "processed"
    }
  ]
}
```

```ts !!request title="Kit"
import { createSolanaRpc, type Commitment } from "@solana/kit";

const rpc_url = "https://api.devnet.solana.com";
const rpc = createSolanaRpc(rpc_url);

// !hover commitment
let commitment: Commitment = "processed";
let latestBlockhash = await rpc.getLatestBlockhash({ commitment }).send();

console.log(latestBlockhash);
```

```ts !!request title="web3.js"
import { Connection, clusterApiUrl, type Commitment } from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("devnet"), "confirmed");

// !hover commitment
let commitment: Commitment = "processed";
let latestBlockhash = await connection.getLatestBlockhash(commitment);

console.log(latestBlockhash);
```

```rs !!request title="Rust"
use anyhow::Result;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_commitment_config::CommitmentConfig;

#[tokio::main]
async fn main() -> Result<()> {
    let client = RpcClient::new_with_commitment(
        String::from("https://api.devnet.solana.com"),
        CommitmentConfig::confirmed(),
    );

    // !hover commitment
    let commitment = CommitmentConfig::processed();
    let latest_blockhash = client
        .get_latest_blockhash_with_commitment(commitment)
        .await?;

    println!("{:#?}", latest_blockhash);

    Ok(())
}
```

### !params

#### !! config

!type object

Configuration object containing the following fields:

##### !! commitment

!type string  
!values processed confirmed finalized  
!default finalized

Solana RPC uses the following commitment levels:

| Value       | Description                                                                                                                                                                                                                                                                |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `processed` | Return data from the highest slot this node has processed on the fork it currently considers best. This is the newest view, but it can still change if the cluster switches forks.                                                                                         |
| `confirmed` | Return data from the highest slot that at least two-thirds of active stake has directly voted to confirm. This is more stable than `processed`, but it is still a weaker guarantee than `finalized`.                                                                       |
| `finalized` | Return data from the highest slot that the cluster recognizes as finalized. In practice, this means the slot has reached maximum vote lockout in validators' vote towers and is recognized by at least two-thirds of active stake. This is the strongest commitment level. |

##### !! minContextSlot

!type number

The minimum slot that the request can be evaluated at

```json title="Example"
{ "minContextSlot": 341197000 }
```

### !!result

```jsonc !response
{
  "jsonrpc": "2.0",
  // !hover(1:10) result
  "result": {
    // !hover(1:4) context
    "context": {
      "apiVersion": "3.1.8",
      "slot": 2792
    },
    // !hover(1:4) value
    "value": {
      "blockhash": "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N",
      "lastValidBlockHeight": 3090
    }
  },
  "id": 1
}
```

!type object

RpcResponse object containing:

#### !! context

!type object

Slot and API version the node used to answer this request.

| Field        | Type     | Description                                                                     |
| ------------ | -------- | ------------------------------------------------------------------------------- |
| `slot`       | `u64`    | Slot at which the node evaluated this request.                                  |
| `apiVersion` | `string` | RPC API version reported by the node. This field may be omitted by older nodes. |

#### !! value

!type object

Latest blockhash response object with the following fields:

| Field                  | Type     | Description                                                                                           |
| ---------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `blockhash`            | `string` | Latest blockhash, as a base-58 encoded string.                                                        |
| `lastValidBlockHeight` | `u64`    | Last [block height](/docs/references/terminology#block-height) at which this blockhash remains valid. |

</APIMethod>
