zetrix_get_ledger
Retrieve blockchain block or ledger data from the Zetrix network, with options to include validator lists, consensus values, and fee configurations for detailed analysis.
Instructions
Get block/ledger information with optional details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seq | No | Block sequence number (optional) | |
| withValidator | No | Include validator list (optional) | |
| withConsValue | No | Include consensus value (optional) | |
| withFee | No | Include fee configuration (optional) |
Implementation Reference
- src/zetrix-client.ts:469-497 (handler)Core handler function that executes the getLedger logic by making an HTTP GET request to the Zetrix API endpoint "/getLedger" with optional parameters for sequence, validators, consensus value, and fees. Handles errors and returns formatted ledger data.async getLedger( seq?: number, withValidator?: boolean, withConsValue?: boolean, withFee?: boolean ): Promise<ZetrixLedger> { try { const params: any = {}; if (seq) params.seq = seq; if (withValidator) params.with_validator = withValidator; if (withConsValue) params.with_consvalue = withConsValue; if (withFee) params.with_fee = withFee; const response = await this.client.get("/getLedger", { params }); if (response.data.error_code !== 0) { throw new Error( response.data.error_desc || `API Error: ${response.data.error_code}` ); } return response.data.result; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Failed to get ledger: ${error.message}`); } throw error; } }
- src/index.ts:955-970 (handler)MCP server tool handler case that parses input arguments and delegates execution to ZetrixClient.getLedger method, then formats the response as MCP content.case "zetrix_get_ledger": { const result = await zetrixClient.getLedger( args?.seq as number | undefined, args?.withValidator as boolean | undefined, args?.withConsValue as boolean | undefined, args?.withFee as boolean | undefined ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:229-253 (registration)MCP tool registration including name, description, and input schema definition for validation.{ name: "zetrix_get_ledger", description: "Get block/ledger information with optional details", inputSchema: { type: "object", properties: { seq: { type: "number", description: "Block sequence number (optional)", }, withValidator: { type: "boolean", description: "Include validator list (optional)", }, withConsValue: { type: "boolean", description: "Include consensus value (optional)", }, withFee: { type: "boolean", description: "Include fee configuration (optional)", }, }, }, },
- src/zetrix-client.ts:90-107 (schema)TypeScript interface defining the structure of the ledger response data (output schema).export interface ZetrixLedger { header: { seq: number; hash: string; previous_hash: string; account_tree_hash: string; close_time: number; consensus_value_hash: string; fees_hash: string; tx_count: number; validators_hash: string; version: number; }; transactions?: any[]; validators?: any[]; consensus_value?: any; fees?: any; }