get_transaction
Retrieve detailed transaction information by providing a transaction hash. Works with Arbitrum Nitro nodes and chains, enabling precise chain health monitoring and node operations.
Instructions
Get transaction details by hash
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rpcUrl | No | The RPC URL of the chain (optional if default is set) | |
| txHash | Yes | Transaction hash |
Implementation Reference
- src/index.ts:270-286 (handler)MCP tool handler for 'get_transaction': resolves RPC URL or chain name, instantiates EthereumAccountClient, fetches transaction by txHash, and returns JSON-formatted transaction details.case "get_transaction": { const rpcUrl = await this.resolveRpcUrl( (args.rpcUrl as string) || (args.chainName as string) ); const ethereumAccountClient = new EthereumAccountClient(rpcUrl); const tx = await ethereumAccountClient.getTransaction( args.txHash as string ); return { content: [ { type: "text", text: JSON.stringify(tx, null, 2), }, ], }; }
- src/index.ts:982-999 (registration)Tool registration in getAvailableTools(): defines name 'get_transaction', description, and input schema requiring txHash (rpcUrl optional).name: "get_transaction", description: "Get transaction details by hash", inputSchema: { type: "object" as const, properties: { rpcUrl: { type: "string", description: "The RPC URL of the chain (optional if default is set)", }, txHash: { type: "string", description: "Transaction hash", }, }, required: ["txHash"], }, },
- TypeScript interface defining the structure of a Transaction object returned by the tool.export interface Transaction { hash: string; nonce: number; blockHash: string | null; blockNumber: number | null; transactionIndex: number | null; from: string; to: string | null; value: string; gasPrice: string; gas: number; input: string; }
- Core helper function getTransaction: performs eth_getTransactionByHash RPC call via makeRpcCall, parses raw response into typed Transaction, handles not found error.async getTransaction(txHash: string): Promise<Transaction> { const tx = await this.makeRpcCall('eth_getTransactionByHash', [txHash]); if (!tx) { throw new Error(`Transaction ${txHash} not found`); } return { hash: tx.hash, nonce: parseInt(tx.nonce, 16), blockHash: tx.blockHash, blockNumber: tx.blockNumber ? parseInt(tx.blockNumber, 16) : null, transactionIndex: tx.transactionIndex ? parseInt(tx.transactionIndex, 16) : null, from: tx.from, to: tx.to, value: tx.value, gasPrice: tx.gasPrice, gas: parseInt(tx.gas, 16), input: tx.input }; }