# getLatestBlockhash

> Returns a recent blockhash and the last block height it remains valid through.

Source: https://docs.constant-k.com/rpc/http/getlatestblockhash/

`getLatestBlockhash` returns a blockhash for a transaction's `recentBlockhash` field, and the `lastValidBlockHeight` at which it expires. Every transaction must reference a recent blockhash so the network can detect and drop duplicates and stale transactions.

A blockhash is valid for about 150 blocks, roughly a minute; transaction-building flows typically fetch one immediately before signing rather than caching it.

- Transport: HTTP, JSON-RPC 2.0 `POST` to `https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY` (New York) or `https://rpc-frankfurt.constant-k.com/?api-key=YOUR_API_KEY` (Frankfurt) or `https://rpc-amsterdam.constant-k.com/?api-key=YOUR_API_KEY` (Amsterdam). The key also works as an `x-api-key` header.
- Category: Fees & Blockhash
- Availability: Operator and above
- Rate limits: Free not available · Operator 50/s · Blade Runner 200/s · Nexus 500/s

## Parameters

`params` is a positional JSON array, in this order:

- `config` (object, optional): Optional configuration.
  - `commitment` (string, optional, one of `finalized`, `confirmed`, `processed`, default `"finalized"`): Bank state to read the blockhash from. `processed` gives the newest possible blockhash but carries the highest risk of referencing a block that gets skipped.
  - `minContextSlot` (integer, optional): Minimum slot the node must have processed before answering.

## Result

- `result` (object, optional): The blockhash and its expiry height, wrapped with context.
  - `context` (object, required)
    - `slot` (integer, optional)
    - `apiVersion` (string, optional)
  - `value` (object, required)
    - `blockhash` (string, required): Base-58 encoded blockhash.
    - `lastValidBlockHeight` (integer, required): Last block height at which this blockhash will be accepted for fee calculation and transaction validity.

## Example: Get the latest blockhash

Request:

```bash
curl "https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getLatestBlockhash",
    "params": []
  }'
```

Response:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "apiVersion": "4.3.0-rc.0",
      "slot": 447946636
    },
    "value": {
      "blockhash": "5p337k1MsPKeS2BgMpkP74BegPfJ9mjsNo5kcb1ns5iQ",
      "lastValidBlockHeight": 425987850
    }
  },
  "id": 1
}
```

## Notes

- A transaction's `lastValidBlockHeight`, compared against the current `getBlockHeight`, indicates whether it is still safe to (re)broadcast.
- Not available on the Free plan.

