isBlockhashValid
Returns whether a blockhash is still valid or not
Common use cases
| Pre-submission validation | Validate a blockhash provided by an external wallet or cached from an earlier call before submitting a transaction. Prevents wasting fees on transactions that will immediately fail due to expired blockhashes. |
| Retry decision logic | Check if a failed transaction's blockhash is still valid before retrying. When isBlockhashValid returns false, the transaction should be rebuilt with a fresh blockhash from getLatestBlockhash instead of retrying. |
Parameters
blockhash (string, required)
The blockhash of the block to evaluate, as base-58 encoded string
config (object, optional)
Configuration object containing the following fields:
Fields:
commitment(string): The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.minContextSlot(number): The minimum slot that the request can be evaluated at
Request
- cURL
- JavaScript
- Python
curl https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 45,
"method": "isBlockhashValid",
"params": [
"J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW",
{
"commitment": "processed"
}
]
}'
// Using fetch
const response = await fetch('https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 45,
"method": "isBlockhashValid",
"params": [
"J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW",
{
"commitment": "processed"
}
]
})
});
const data = await response.json();
console.log(data);
import requests
import json
url = 'https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
data = {
"jsonrpc": "2.0",
"id": 45,
"method": "isBlockhashValid",
"params": [
"J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW",
{
"commitment": "processed"
}
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Replace mainnet with devnet in the URL to query devnet instead.
Response
{
"jsonrpc": "2.0",
"result": {
"context": { "slot": 2483 },
"value": false
},
"id": 45
}
Response Fields
Return value: bool
Whether the blockhash is still valid
FAQ and Troubleshooting
Why does isBlockhashValid return true but my transaction still fails with "blockhash not found"?
Transactions expire when their blockhash is no longer in the 150 most recent blocks, not when isBlockhashValid returns false. The method checks the blockhash queue at query time, but block production continues. Always fetch a fresh blockhash immediately before transaction submission.
What's the difference between checking isBlockhashValid vs tracking lastValidBlockHeight from getLatestBlockhash?
isBlockhashValid validates any blockhash against current chain state, while lastValidBlockHeight (from getLatestBlockhash) tells you exactly when a specific blockhash expires. Use lastValidBlockHeight for deterministic expiration checks; use isBlockhashValid when you only have the blockhash (e.g., from external sources).
Does isBlockhashValid work with durable nonces?
No. Durable nonces have different expiration semantics and should be validated through nonce account queries, not isBlockhashValid. This method only validates regular blockhashes subject to the 150-block expiration window.
Related Methods
getLatestBlockhash
Returns the most recent blockhash and its last valid block height. Use together with isBlockhashValid in transaction workflows: fetch fresh blockhash with this method, then validate cached blockhashes with isBlockhashValid.
getBlockHeight
Returns current block height at specified commitment. Compare with lastValidBlockHeight from getLatestBlockhash to determine if a blockhash has expired, complementing isBlockhashValid checks.
sendTransaction
Submits a signed transaction to the cluster. Call isBlockhashValid before this method to avoid submitting transactions with expired blockhashes, reducing failed transaction fees.
External Resources
- Solana Official Documentation
- Transaction Confirmation - Solana Docs - Official documentation on transaction expiration mechanics and the 150-block validity window for blockhashes.