isBlockhashValid - Solana
The isBlockhashValid JSON-RPC method checks whether a specific blockhash is still valid for submitting transactions on the Solana blockchain.
Last updated
Was this helpful?
Was this helpful?
curl --location "https://go.getblock.io/<ACCESS-TOKEN>/" -XPOST \
--header "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "isBlockhashValid",
"params": [
"J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW",
{ "commitment": "finalized" }
]
}'{
"jsonrpc": "2.0",
"result": true,
"id": "getblock.io"
}{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid blockhash format"
},
"id": "getblock.io"
}const axios = require('axios');
const url = "https://go.getblock.io/<ACCESS-TOKEN>/";
const headers = { "Content-Type": "application/json" };
const payload = {
jsonrpc: "2.0",
id: 1,
method: "isBlockhashValid",
params: [
"J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW",
{ "commitment": "finalized" }
]
};
const checkBlockhashValidity = async () => {
try {
const response = await axios.post(url, payload, { headers });
if (response.status === 200) {
const isValid = response.data.result;
console.log("Blockhash Valid:", isValid);
} else {
console.error("Unexpected response:", response.data);
}
} catch (error) {
console.error("isBlockhashValid error:", error.response?.data || error.message);
}
};
checkBlockhashValidity();