TriportRPC

isBlockhashValid

POSThttps://api.triport.io/v1/sol

Returns whether a given Solana blockhash is still valid (has not yet expired).

Solanasol_read_rpcfree+ — 20 / 60 / 200 / 600 RPS (free / basic / pro / business)

isBlockhashValid reports whether a blockhash is still valid against the cluster. A Solana blockhash expires after roughly 150 slots (about a minute), after which any transaction that references it is rejected. Use this method to confirm a recent blockhash is still usable before submitting a transaction, or to decide whether you need to fetch a fresh one with getLatestBlockhash and re-sign.

The answer is wrapped in the standard RPC response envelope, so you also get the context.slot at which it was evaluated. A value of true means the blockhash is still valid at that slot; false means it has expired (or was never seen) and you should obtain a new one.

Because validity is slot-dependent, the result is a point-in-time snapshot. Use the optional commitment config to control how finalized that slot must be, and minContextSlot to require that the node has reached at least a given slot before serving the request.

Parameters

JSON-RPC params is a positional array: [blockhash, config?].

blockhashstring (base-58)required
The blockhash to evaluate, as a base-58 encoded string.
configobjectoptional
Optional configuration object (see below).
commitmentstringoptional
Commitment level: processed, confirmed, or finalized.
minContextSlotintegeroptional
Minimum slot the request must be evaluated at.

Response

Response fields

FieldTypeDescription
resultobjectRpcResponseBool envelope.
result.contextobjectThe context the response was evaluated against.
result.context.slotintegerThe slot at which the blockhash validity was evaluated.
result.context.apiVersionstringThe node software version that served the request.
result.valuebooleantrue if the blockhash is still valid, false if it has expired or is unknown.

Errors

Errors are returned in the standard JSON-RPC error envelope. See the shared errors reference for the full envelope shape and shared codes.

CodeMeaningWhen it happens
-32602Invalid paramsblockhash is missing, not a string, or not valid base-58; or config is malformed.
401UnauthorizedMissing or invalid Authorization: Bearer key.
429Rate limitedMore than your tier's RPS for sol_read_rpc (20 / 60 / 200 / 600).

Examples

JavaScript (fetch)

const res = await fetch("https://api.triport.io/v1/sol", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "isBlockhashValid",
    params: ["AaTs4Vs2sJ9bJq9rWvY3sJ6Qf2bC8mNpRtWuYxZ1Hc9", { commitment: "confirmed" }],
  }),
});


const { result } = await res.json();
console.log(result.value ? "still valid" : "expired — fetch a new blockhash");

TypeScript SDK (@triport/sdk)

import { TriportClient } from "@triport/sdk";


const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY });


const { context, value } = await client.solana.isBlockhashValid(
  "AaTs4Vs2sJ9bJq9rWvY3sJ6Qf2bC8mNpRtWuYxZ1Hc9",
  { commitment: "confirmed" }
);


console.log(`valid=${value} (slot ${context.slot})`);

Python (triport-sdk)

import os
from triport import TriportClient


client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])


result = client.solana.is_blockhash_valid(
    "AaTs4Vs2sJ9bJq9rWvY3sJ6Qf2bC8mNpRtWuYxZ1Hc9",
    commitment="confirmed",
)


print(f"valid={result['value']} (slot {result['context']['slot']})")

Notes

  • Pre-flight check before sending: the typical flow is getLatestBlockhash → build and sign the transaction → optionally call isBlockhashValid right before sendTransaction. If value is false, fetch a fresh blockhash and re-sign rather than submitting a doomed transaction.
  • Snapshot semantics: the result is evaluated at context.slot; a blockhash that is valid now may expire moments later. Re-check if there is significant delay between the call and submission.
  • Avoid stale reads: pass minContextSlot when you need a guarantee that the answer reflects at least a given slot; the node errors instead of returning a result from behind that slot.
  • Commitment defaults: when commitment is omitted, the node's default commitment applies. Pass finalized for the strongest consistency guarantee.
  • Related methods: getLatestBlockhash to obtain a fresh blockhash, and getFeeForMessage to price a message before signing.