Skip to main content
Glama

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

NameRequiredDescriptionDefault
commitmentNo

Input Schema (JSON Schema)

{ "properties": { "commitment": { "enum": [ "confirmed", "finalized", "processed" ], "type": "string" } }, "required": [], "type": "object" }

Implementation Reference

  • 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)}`); } }
  • 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,
  • TypeScript type definition for the handler input.
    export type GetLatestBlockhashInput = { commitment?: "confirmed" | "finalized" | "processed"; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dcSpark/mcp-server-helius'

If you have feedback or need assistance with the MCP directory API, please join our Discord server