get-transaction
Retrieve blockchain transaction details using hash and chain ID with a MetaMask-integrated tool, enabling secure and direct interaction with blockchain data.
Instructions
Fetch transaction given hash or block identifiers.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | No | ID of chain to use when fetching data. | |
| hash | Yes | Hash to get transaction. |
Implementation Reference
- src/tools/get-transaction.ts:16-26 (handler)The execute handler for the get-transaction tool. Fetches the transaction using wagmi's getTransaction with the wagmi config and args, stringifies the result using JSONStringify, and returns it as text content in the MCP format.execute: async (args) => { const result = await getTransaction(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; },
- src/tools/get-transaction.ts:12-15 (schema)Zod schema for input parameters: 'hash' (TransactionHash type) and optional 'chainId' (coerced number).parameters: z.object({ hash: TransactionHash.describe("Hash to get transaction."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }),
- src/tools/get-transaction.ts:9-27 (registration)Direct registration of the 'get-transaction' tool on the FastMCP server instance using server.addTool, specifying name, description, input schema, and execute handler.server.addTool({ name: "get-transaction", description: "Fetch transaction given hash or block identifiers.", parameters: z.object({ hash: TransactionHash.describe("Hash to get transaction."), chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."), }), execute: async (args) => { const result = await getTransaction(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; }, });
- src/tools/register-tools.ts:50-50 (registration)Invocation of the registerGetTransactionTools function within the central registerTools function, which registers multiple tools.registerGetTransactionTools(server, wagmiConfig);
- src/index.ts:15-15 (registration)Top-level call to registerTools in the main index file, which chains to registering the get-transaction tool.registerTools(server, wagmiConfig);