decodeTransactionData
Decode transaction data in hex format using Safe smart contract wallet APIs. Extract and interpret transaction details for clarity and analysis.
Instructions
Decode transaction data using Safe API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Transaction data in hex format | |
| to | No | Optional contract address |
Implementation Reference
- src/index.ts:194-224 (handler)The handler for the 'decodeTransactionData' tool. It performs a POST request to the Safe API's data-decoder endpoint with the transaction data (and optional 'to' address), handles specific HTTP errors, and returns the decoded transaction data as a JSON string.case "decodeTransactionData": { const { data, to } = args as any; const response = await fetch(`${SAFE_API_URL}/data-decoder/`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ data, to }), }); if (!response.ok) { if (response.status === 404) { throw new McpError( ErrorCode.InternalError, "Cannot find function selector" ); } if (response.status === 422) { throw new McpError(ErrorCode.InvalidParams, "Invalid data"); } throw new McpError( ErrorCode.InternalError, `Decoder API error: ${response.statusText}` ); } const decodedData = await response.json(); return { content: [ { type: "text", text: JSON.stringify(decodedData, null, 2) }, ], }; }
- src/index.ts:143-160 (registration)Tool registration in the ListTools response, defining the name, description, and input schema for 'decodeTransactionData'.{ name: "decodeTransactionData", description: "Decode transaction data using Safe API", inputSchema: { type: "object", properties: { data: { type: "string", description: "Transaction data in hex format", }, to: { type: "string", description: "Optional contract address", }, }, required: ["data"], }, },