Learn isBlockhashValid use cases, code examples, request parameters, response structure, and tips.
isBlockhashValid
RPC method checks whether a previously obtained blockhash is still considered valid by the network. Blockhashes have a limited lifetime (approximately 2 minutes, or 150 blocks), after which transactions referencing them will be rejected.
This method is crucial for applications that hold onto blockhashes for some time before submitting a transaction, to ensure the transaction doesn’t fail due to an expired blockhash.
Version Note: This method is available in solana-core
v1.9 and newer. For nodes running solana-core
v1.8 or older, you should use getFeeCalculatorForBlockhash
which, in addition to fee information, also implicitly indicates blockhash validity (it will error if the blockhash is too old).
blockhash
(string, required): The blockhash to check, as a base-58 encoded string.options
(object, optional): An optional configuration object that can include:
commitment
(string, optional): Specifies the commitment level for the query (e.g., "finalized"
, "confirmed"
, "processed"
). If omitted, the node’s default commitment is used.minContextSlot
(u64, optional): The minimum slot that the request can be evaluated at. This ensures the RPC node does not respond with a status from a slot older than the minContextSlot
.result
field in the JSON-RPC response is an RpcResponse
object containing:
context
(object): An object containing:
slot
(u64): The slot at which the RPC node evaluated the blockhash validity.value
(boolean): true
if the blockhash is still valid, false
otherwise.minContextSlot
Usage: Use minContextSlot
to protect against querying a stale RPC node that might give an outdated “valid” response for a blockhash that is actually too old from the perspective of the rest of the cluster.getFeeCalculatorForBlockhash("<YOUR_BLOCKHASH>")
. If this method returns successfully, the blockhash is valid. If it errors (typically because the blockhash is not found or too old), then the blockhash is invalid.isBlockhashValid
returns true
, a transaction is only finalized once it reaches the desired commitment level on the network after submission.isBlockhashValid
RPC method effectively when building Solana applications.