block_heights
Retrieve block heights and timestamps for historical blockchain analysis by specifying a date range and blockchain network.
Instructions
Commonly used to get all the block heights within a particular date range. Requires chainName (blockchain network), startDate (YYYY-MM-DD format), and endDate (YYYY-MM-DD or 'latest'). Optional pagination parameters include pageSize (default 10) and pageNumber (default 0). Returns block heights, timestamps, and related data for blocks within the specified date range, useful for historical analysis and time-based blockchain queries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainName | Yes | The blockchain network to query (e.g., 'eth-mainnet', 'matic-mainnet', 'bsc-mainnet'). | |
| startDate | Yes | Start date for the query in YYYY-MM-DD format (e.g., '2023-01-01'). | |
| endDate | Yes | End date for the query in YYYY-MM-DD format or 'latest' for current date. | |
| pageSize | No | Number of block heights to return per page. Default is 10, maximum is 100. | |
| pageNumber | No | Page number for pagination, starting from 0. Default is 0. |
Implementation Reference
- src/services/BaseService.ts:120-185 (handler)The "block_heights" tool definition and handler implementation in BaseService.ts. It registers the tool with the MCP server, defines the input schema using Zod, and executes the logic by calling 'goldRushClient.BaseService.getBlockHeightsByPage'.
server.tool( "block_heights", "Commonly used to get all the block heights within a particular date range. " + "Requires chainName (blockchain network), startDate (YYYY-MM-DD format), and endDate (YYYY-MM-DD or 'latest'). " + "Optional pagination parameters include pageSize (default 10) and pageNumber (default 0). " + "Returns block heights, timestamps, and related data for blocks within the specified date range, " + "useful for historical analysis and time-based blockchain queries.", { chainName: z .enum(Object.values(ChainName) as [string, ...string[]]) .describe( "The blockchain network to query (e.g., 'eth-mainnet', 'matic-mainnet', 'bsc-mainnet')." ), startDate: z .string() .describe( "Start date for the query in YYYY-MM-DD format (e.g., '2023-01-01')." ), endDate: z .union([z.string(), z.literal("latest")]) .describe( "End date for the query in YYYY-MM-DD format or 'latest' for current date." ), pageSize: z .number() .optional() .default(10) .describe( "Number of block heights to return per page. Default is 10, maximum is 100." ), pageNumber: z .number() .optional() .default(0) .describe( "Page number for pagination, starting from 0. Default is 0." ), }, async (params) => { try { const response = await goldRushClient.BaseService.getBlockHeightsByPage( params.chainName as Chain, params.startDate, params.endDate, { pageSize: params.pageSize, pageNumber: params.pageNumber, } ); return { content: [ { type: "text", text: stringifyWithBigInt(response.data), }, ], }; } catch (err) { return { content: [{ type: "text", text: `Error: ${err}` }], isError: true, }; } } );