get-block-txid-by-index
Retrieve the transaction ID (txid) from a specific block by providing the block hash and the transaction index within the block. Ideal for accessing precise Bitcoin blockchain data.
Instructions
Returns txid for a block at a specific index
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hash | Yes | The block hash to get txid for | |
| index | Yes | The index of the txid in the block |
Implementation Reference
- src/interface/controllers/BlocksToolsController.ts:90-101 (registration)Registration of the MCP tool 'get-block-txid-by-index' including name, description, input schema, and handler function.this.server.tool( "get-block-txid-by-index", "Returns txid for a block at a specific index", { hash: z.string().length(64).describe("The block hash to get txid for"), index: z.number().int().describe("The index of the txid in the block"), }, async ({ hash, index }) => { const text = await this.blocksService.getBlockTxidByIndex({ hash, index }); return { content: [{ type: "text", text }] }; } );
- The handler function that executes the tool's core logic: calls BlocksService and formats the response as MCP content.async ({ hash, index }) => { const text = await this.blocksService.getBlockTxidByIndex({ hash, index }); return { content: [{ type: "text", text }] }; }
- Zod schema defining input parameters: hash (string length 64) and index (integer).{ hash: z.string().length(64).describe("The block hash to get txid for"), index: z.number().int().describe("The index of the txid in the block"), },
- Application service method that delegates to infrastructure request service and formats the txid response.async getBlockTxidByIndex({ hash, index, }: { hash: string; index: number; }): Promise<string> { const data = await this.requestService.getBlockTxidByIndex({ hash, index }); return `Block Txid By Index: ${data}`; }
- Infrastructure service method implementing the API request to fetch txid by index for a block.async getBlockTxidByIndex({ hash, index }: { hash: string; index: number }): Promise<string | null> { return this.client.makeRequest<string>(`block/${hash}/txid/${index}`); }