get_block_by_hash
Retrieve blockchain block details using a specific block hash. Supports multiple networks, including BSC, Ethereum, and others, with BSC mainnet as default.
Instructions
Get a block by hash
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockHash | Yes | The block hash to look up | |
| network | No | Network name (e.g. 'bsc', 'opbnb', 'ethereum', 'base', etc.) or chain ID. Supports others main popular networks. Defaults to BSC mainnet. | bsc |
Implementation Reference
- src/evm/modules/blocks/tools.ts:11-26 (registration)MCP tool registration for 'get_block_by_hash', including description, input schema, and handler function.server.tool( "get_block_by_hash", "Get a block by hash", { blockHash: z.string().describe("The block hash to look up"), network: defaultNetworkParam }, async ({ network, blockHash }) => { try { const block = await services.getBlockByHash(blockHash as Hash, network) return mcpToolRes.success(block) } catch (error) { return mcpToolRes.error(error, "fetching block by hash") } } )
- src/evm/modules/blocks/tools.ts:18-25 (handler)Handler function that executes the tool: fetches block via service and returns MCP-formatted response.async ({ network, blockHash }) => { try { const block = await services.getBlockByHash(blockHash as Hash, network) return mcpToolRes.success(block) } catch (error) { return mcpToolRes.error(error, "fetching block by hash") } }
- Input schema using Zod for tool parameters (blockHash and network).{ blockHash: z.string().describe("The block hash to look up"), network: defaultNetworkParam },
- src/evm/services/blocks.ts:27-33 (helper)Helper service function that retrieves a block by its hash using the viem public client.export async function getBlockByHash( blockHash: Hash, network = "ethereum" ): Promise<Block> { const client = getPublicClient(network) return await client.getBlock({ blockHash }) }
- src/evm/modules/blocks/index.ts:8-8 (registration)Higher-level registration call to registerBlockTools within the blocks module.registerBlockTools(server)