block
Retrieve comprehensive chain data at a given height: includes timestamp, transaction count, size, and miner information. Provide chain name and height.
Instructions
Commonly used to fetch and render a single block for a block explorer.Requires chainName (blockchain network) and blockHeight (block number). Returns comprehensive block data including timestamp, transaction count, size, miner information, and other blockchain-specific details.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainName | Yes | The blockchain network to query (e.g., 'eth-mainnet', 'matic-mainnet', 'bsc-mainnet'). | |
| blockHeight | Yes | The block number to retrieve. Can be a specific block number or 'latest' for the most recent block. |
Implementation Reference
- src/services/BaseService.ts:79-117 (registration)The 'block' tool is registered via server.tool() with name 'block', description, Zod schema (chainName, blockHeight), and handler callback.
server.tool( "block", "Commonly used to fetch and render a single block for a block explorer." + "Requires chainName (blockchain network) and blockHeight (block number). " + "Returns comprehensive block data including timestamp, transaction count, size, " + "miner information, and other blockchain-specific details.", { chainName: z .enum(Object.values(ChainName) as [string, ...string[]]) .describe( "The blockchain network to query (e.g., 'eth-mainnet', 'matic-mainnet', 'bsc-mainnet')." ), blockHeight: z .string() .describe( "The block number to retrieve. Can be a specific block number or 'latest' for the most recent block." ), }, async (params) => { try { const response = await goldRushClient.BaseService.getBlock( params.chainName as Chain, params.blockHeight ); return { content: [ { type: "text", text: stringifyWithBigInt(response.data), }, ], }; } catch (err) { return { content: [{ type: "text", text: `Error: ${err}` }], isError: true, }; } } - src/services/BaseService.ts:97-117 (handler)The handler function for the 'block' tool. Calls goldRushClient.BaseService.getBlock(chainName, blockHeight) and returns the response data stringified with BigInt support.
async (params) => { try { const response = await goldRushClient.BaseService.getBlock( params.chainName as Chain, params.blockHeight ); return { content: [ { type: "text", text: stringifyWithBigInt(response.data), }, ], }; } catch (err) { return { content: [{ type: "text", text: `Error: ${err}` }], isError: true, }; } } - src/services/BaseService.ts:85-96 (schema)Zod input schema for the 'block' tool: chainName (enum of ChainName values) and blockHeight (string, can be specific block number or 'latest').
{ chainName: z .enum(Object.values(ChainName) as [string, ...string[]]) .describe( "The blockchain network to query (e.g., 'eth-mainnet', 'matic-mainnet', 'bsc-mainnet')." ), blockHeight: z .string() .describe( "The block number to retrieve. Can be a specific block number or 'latest' for the most recent block." ), }, - src/utils/helpers.ts:7-13 (helper)stringifyWithBigInt helper used by the block tool handler to safely serialize BigInt values in JSON responses.
export function stringifyWithBigInt(value: any): string { return JSON.stringify( value, (_, val) => (typeof val === "bigint" ? val.toString() : val), 2 ); } - src/server.ts:67-69 (registration)The 'block' tool is indirectly registered via addBaseServiceTools(server, goldRushClient) call on line 69.
// Add service tools addAllChainsServiceTools(server, goldRushClient); addBaseServiceTools(server, goldRushClient);