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
| Name | Required | Description | Default |
|---|---|---|---|
| blockHashOrBlockTag | Yes | Block hash or block tag (latest, pending, etc.) | |
| includeTransactions | No | Whether to include full transactions or just hashes |
Implementation Reference
- src/handlers/wallet.ts:496-517 (handler)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}`); } };
- src/tools.ts:391-402 (schema)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,