helius_get_latest_blockhash
Retrieve the most recent blockhash from the Solana blockchain to verify transaction timestamps or ensure data consistency, using specified commitment levels for accuracy.
Instructions
Get the latest blockhash from the Solana blockchain
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commitment | No |
Input Schema (JSON Schema)
{
"properties": {
"commitment": {
"enum": [
"confirmed",
"finalized",
"processed"
],
"type": "string"
}
},
"required": [],
"type": "object"
}
Implementation Reference
- src/handlers/helius.ts:128-135 (handler)The core handler function that executes the tool logic by calling the Helius SDK's connection.getLatestBlockhash method and formatting the response.export const getLatestBlockhashHandler = async (input: GetLatestBlockhashInput): Promise<ToolResultSchema> => { try { const { blockhash, lastValidBlockHeight } = await (helius as any as Helius).connection.getLatestBlockhash(input.commitment); return createSuccessResponse(`Latest blockhash: ${blockhash}, Last valid block height: ${lastValidBlockHeight}`); } catch (error) { return createErrorResponse(`Error getting latest blockhash: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools.ts:91-101 (schema)Defines the tool's input schema, description, and registration in the tools array.{ name: "helius_get_latest_blockhash", description: "Get the latest blockhash from the Solana blockchain", inputSchema: { type: "object", properties: { commitment: { type: "string", enum: ["confirmed", "finalized", "processed"] } }, required: [] } },
- src/tools.ts:555-555 (registration)Maps the tool name to its handler function in the handlers dictionary."helius_get_latest_blockhash": getLatestBlockhashHandler,
- src/handlers/helius.types.ts:56-58 (schema)TypeScript type definition for the handler input.export type GetLatestBlockhashInput = { commitment?: "confirmed" | "finalized" | "processed"; }