Skip to main content
Glama

provider_get_block

Retrieve Ethereum or EVM-compatible blockchain block details by specifying a block hash, number, or tag. Optionally include full transaction data for comprehensive insights.

Instructions

Get a block by number or hash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockHashOrBlockTagYesBlock hash or block tag (latest, pending, etc.)
includeTransactionsNoWhether to include full transactions or just hashes

Implementation Reference

  • The handler function that implements the core logic for 'provider_get_block' tool. It uses the provider to fetch the block by hash or tag, optionally including transactions, and returns formatted success or error response.
    export const getBlockHandler = async (input: any): Promise<ToolResultSchema> => { try { if (!input.blockHashOrBlockTag) { return createErrorResponse("Block hash or block tag is required"); } const provider = getProvider(); // In ethers.js v5, getBlock can take includeTransactions as a second parameter // but TypeScript definitions might not reflect this const block = await (provider as any).getBlock(input.blockHashOrBlockTag, input.includeTransactions); return createSuccessResponse( `Block retrieved successfully Block hash: ${block.hash} Block number: ${block.number?.toString() ?? "Not specified"} Block timestamp: ${block.timestamp?.toString() ?? "Not specified"} Block transactions: ${block.transactions?.length ?? "Not specified"} `); } catch (error) { return createErrorResponse(`Failed to get block: ${(error as Error).message}`); } };
  • The schema definition for the 'provider_get_block' tool, specifying input parameters and validation.
    { name: "provider_get_block", description: "Get a block by number or hash", inputSchema: { type: "object", properties: { blockHashOrBlockTag: { type: "string", description: "Block hash or block tag (latest, pending, etc.)" }, includeTransactions: { type: "boolean", description: "Whether to include full transactions or just hashes" } }, required: ["blockHashOrBlockTag"] } },
  • src/tools.ts:590-590 (registration)
    The registration of the 'provider_get_block' tool name to its handler function in the handlers dictionary.
    "provider_get_block": getBlockHandler,

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-cryptowallet-evm'

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