zetrix_get_ledger
Retrieve block or ledger information from the Zetrix blockchain with optional details including validator lists, consensus values, and fee configurations.
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 implementation: Makes HTTP GET request to Zetrix RPC /getLedger endpoint with optional seq, with_validator, with_consvalue, with_fee parameters and returns 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:229-253 (registration)Tool registration in the MCP tools list, including name, description, and input schema.{ 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/index.ts:955-970 (handler)MCP server dispatch handler: Extracts arguments and calls ZetrixClient.getLedger, formats response for MCP protocol.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/zetrix-client.ts:90-107 (schema)TypeScript interface defining the structure of ledger response data.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; }