get_cosmos_block
Retrieve Cosmos blockchain block data at a specific height to analyze transactions, validate network activity, or inspect chain state using Grove's Pocket Network endpoints.
Instructions
Get Cosmos block at specific height
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockchain | Yes | Blockchain name | |
| height | Yes | Block height | |
| network | No | Network type (defaults to mainnet) |
Implementation Reference
- src/handlers/cosmos-handlers.ts:631-647 (handler)Handler execution logic for the 'get_cosmos_block' tool: extracts parameters and delegates to CosmosService.getBlockByHeightcase 'get_cosmos_block': { const blockchain = args?.blockchain as string; const height = args?.height as number; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await cosmosService.getBlockByHeight(blockchain, height, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- Input schema definition for the 'get_cosmos_block' tool, specifying required blockchain and height parametersname: 'get_cosmos_block', description: 'Get Cosmos block at specific height', inputSchema: { type: 'object', properties: { blockchain: { type: 'string', description: 'Blockchain name', }, height: { type: 'number', description: 'Block height', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['blockchain', 'height'], },
- src/index.ts:88-101 (registration)Registration of all tools including 'get_cosmos_block' via registerCosmosHandlers in the tools list used for ListToolsRequestHandlerconst tools: Tool[] = [ ...registerBlockchainHandlers(server, blockchainService), ...registerDomainHandlers(server, domainResolver), ...registerTransactionHandlers(server, advancedBlockchain), ...registerTokenHandlers(server, advancedBlockchain), ...registerMultichainHandlers(server, advancedBlockchain), ...registerContractHandlers(server, advancedBlockchain), ...registerUtilityHandlers(server, advancedBlockchain), ...registerEndpointHandlers(server, endpointManager), ...registerSolanaHandlers(server, solanaService), ...registerCosmosHandlers(server, cosmosService), ...registerSuiHandlers(server, suiService), ...registerDocsHandlers(server, docsManager), ];
- Core helper method in CosmosService that fetches the specific Cosmos block by height using REST APIasync getBlockByHeight( blockchain: string, height: number, network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { try { const baseUrl = this.getRestUrl(blockchain, network); const url = `${baseUrl}/cosmos/base/tendermint/v1beta1/blocks/${height}`; return this.fetchRest(url); } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get Cosmos block', }; } }