get_transaction
Retrieve detailed information about a specific transaction on the Rootstock blockchain by providing its unique hash using the Rootstock MCP Server.
Instructions
Get details of a transaction by hash
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hash | Yes | Transaction hash |
Implementation Reference
- src/index.ts:694-711 (handler)Primary MCP tool handler for 'get_transaction'. Fetches transaction details from Rootstock client and formats response with explorer link.private async handleGetTransaction(params: GetTransactionParams) { try { const transaction = await this.rootstockClient.getTransaction(params.hash); const explorerUrl = this.rootstockClient.getExplorerUrl(); const txExplorerLink = `${explorerUrl}/tx/${transaction.hash}`; return { content: [ { type: 'text', text: `Transaction Details:\n\nHash: ${transaction.hash}\nExplorer: ${txExplorerLink}\n\nFrom: ${transaction.from}\nTo: ${transaction.to}\nValue: ${transaction.value} ${this.rootstockClient.getCurrencySymbol()}\nGas Used: ${transaction.gasUsed}\nBlock: ${transaction.blockNumber}\nStatus: ${transaction.status}`, }, ], }; } catch (error) { throw new Error(`Failed to get transaction: ${error}`); } }
- src/index.ts:256-268 (registration)Tool registration in getAvailableTools() method, defining name, description, and input schema for listTools response.name: 'get_transaction', description: 'Get details of a transaction by hash', inputSchema: { type: 'object', properties: { hash: { type: 'string', description: 'Transaction hash', }, }, required: ['hash'], }, },
- src/types.ts:131-133 (schema)TypeScript interface defining input parameters for the get_transaction tool.export interface GetTransactionParams { hash: string; }
- src/smithery-server.ts:366-395 (handler)Alternative handler/registration in Smithery server variant using direct server.tool() call.// Get Transaction Tool server.tool( "get_transaction", "Get details of a transaction by hash", { hash: z.string().describe("Transaction hash"), }, async ({ hash }) => { try { const transaction = await rootstockClient.getTransaction(hash); return { content: [ { type: "text", text: `Transaction Details:\n\nHash: ${transaction.hash}\nFrom: ${transaction.from}\nTo: ${transaction.to}\nValue: ${transaction.value}\nGas Used: ${transaction.gasUsed}\nStatus: ${transaction.status}\nBlock: ${transaction.blockNumber}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error getting transaction: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );
- src/rootstock-client.ts:210-235 (helper)Core blockchain client method implementing the transaction retrieval logic using ethers provider.async getTransaction(hash: string): Promise<TransactionResponse> { try { const [tx, receipt] = await Promise.all([ this.getProvider().getTransaction(hash), this.getProvider().getTransactionReceipt(hash), ]); if (!tx) { throw new Error('Transaction not found'); } return { hash: tx.hash, from: tx.from, to: tx.to || '', value: ethers.formatEther(tx.value), gasUsed: receipt?.gasUsed.toString(), gasPrice: tx.gasPrice?.toString(), blockNumber: receipt?.blockNumber, blockHash: receipt?.blockHash, status: receipt ? (receipt.status === 1 ? 'confirmed' : 'failed') : 'pending', }; } catch (error) { throw new Error(`Failed to get transaction: ${error}`); } }