{
  "openapi": "3.1.1",
  "info": {
    "title": "Transaction Decoder API",
    "version": "1.0.0",
    "summary": "See what an EVM transaction actually did: call, events, token transfers, fee, finality.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://transactiondecoder.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "See what an EVM transaction actually did: call, events, token transfers, fee, finality.",
        "description": "Looks up a transaction on Ethereum, Base, Arbitrum, OP Mainnet, Polygon, Avalanche or BNB Chain straight from a public RPC node and decodes it locally: the function called (from the verified ABI on Sourcify, a built-in table or the signature database), every event log, ERC-20 token transfers with symbols and decimals, gas fee, status and finality. Works offline for raw calldata too.\n\nMethodology:\n- Raw data comes from public JSON-RPC nodes: eth_getTransactionByHash, eth_getTransactionReceipt, eth_getBlockByNumber (timestamp, \"finalized\" tag) and eth_blockNumber.\n- Function: the first 4 bytes (selector) are matched against, in order, your signature/ABI, the verified ABI of the called contract on Sourcify, a built-in table of common functions, then the Sourcify signature database. The first candidate that ABI-decodes cleanly is used; other candidates are listed (selector collisions exist).\n- Events: topic0 is matched the same way. Without a verified ABI, the first (topics − 1) parameters are assumed to be indexed (flagged as indexingAssumed).\n- Token transfers: Transfer(address,address,uint256) logs with exactly 3 topics (ERC-20; ERC-721 has 4); symbol() and decimals() are read with eth_call.\n- Fake-token check: transfers of a token whose symbol is USDT/USDC/WETH/DAI but whose contract is not the official one on that chain are flagged.\n- Finality: \"finalized\" if the block is at or below the chain's \"finalized\" block tag; otherwise \"unfinalized\" with the confirmation count; \"unknown\" if the node does not support the tag.",
        "tags": [
          "web3"
        ],
        "x-mcp-tool": "transaction_decoder",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransactionDecoderInput"
              },
              "examples": {
                "example1": {
                  "summary": "Decode an ERC-20 transfer (offline)",
                  "value": {
                    "mode": "calldata",
                    "chain": "ethereum",
                    "calldata": "0xa9059cbb0000000000000000000000005aaeb6053f3e94c9b9a09f33669435e7ef1beaed00000000000000000000000000000000000000000000000000000000004c4b40"
                  }
                },
                "example2": {
                  "summary": "Custom signature with a tuple (offline)",
                  "value": {
                    "mode": "calldata",
                    "chain": "base",
                    "signature": "setConfig((address,uint256,bool),string)",
                    "calldata": "0xc48cfc700000000000000000000000005aaeb6053f3e94c9b9a09f33669435e7ef1beaed000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000056869676821000000000000000000000000000000000000000000000000000000"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionDecoderResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "TransactionDecoderInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "What do you have?",
            "type": "string",
            "enum": [
              "lookup",
              "calldata"
            ],
            "default": "lookup"
          },
          "chain": {
            "title": "Chain",
            "type": "string",
            "enum": [
              "ethereum",
              "base",
              "arbitrum",
              "optimism",
              "polygon",
              "avalanche",
              "bsc"
            ],
            "default": "ethereum"
          },
          "txHash": {
            "title": "Transaction hash",
            "type": "string",
            "maxLength": 66
          },
          "calldata": {
            "title": "Calldata (input data)",
            "type": "string",
            "maxLength": 200000
          },
          "signature": {
            "title": "Function signature (optional)",
            "type": "string",
            "maxLength": 500
          },
          "abi": {
            "title": "Contract ABI JSON (optional)",
            "type": "string",
            "maxLength": 500000
          }
        },
        "required": []
      },
      "TransactionDecoderResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "mode",
              "chain",
              "transaction",
              "call",
              "logs",
              "tokenTransfers",
              "graph"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "lookup",
                  "calldata"
                ]
              },
              "chain": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "id",
                  "name",
                  "chainId"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "chainId": {
                    "type": "integer"
                  }
                }
              },
              "transaction": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "hash",
                  "status",
                  "finality",
                  "blockNumber",
                  "timestamp",
                  "confirmations",
                  "from",
                  "to",
                  "contractCreated",
                  "valueWei",
                  "value",
                  "gasUsed",
                  "effectiveGasPriceWei",
                  "feeWei",
                  "fee",
                  "nonce",
                  "type"
                ],
                "properties": {
                  "hash": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "success",
                      "reverted",
                      "pending"
                    ]
                  },
                  "finality": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "unfinalized",
                      "finalized",
                      "unknown"
                    ]
                  },
                  "blockNumber": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "timestamp": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "confirmations": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "contractCreated": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "valueWei": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  },
                  "gasUsed": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "effectiveGasPriceWei": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "feeWei": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "fee": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "nonce": {
                    "type": "integer"
                  },
                  "type": {
                    "type": "integer"
                  }
                }
              },
              "call": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "selector",
                  "signature",
                  "signatureSource",
                  "args",
                  "alternatives"
                ],
                "properties": {
                  "selector": {
                    "type": "string"
                  },
                  "signature": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "signatureSource": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "alternatives": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "args": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "name",
                        "type",
                        "value"
                      ],
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              },
              "logs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "index",
                    "address",
                    "topic0",
                    "event",
                    "eventSource",
                    "indexingAssumed",
                    "args"
                  ],
                  "properties": {
                    "index": {
                      "type": "integer"
                    },
                    "address": {
                      "type": "string"
                    },
                    "topic0": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "event": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "eventSource": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "indexingAssumed": {
                      "type": "boolean"
                    },
                    "args": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "name",
                          "type",
                          "indexed",
                          "value"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "indexed": {
                            "type": "boolean"
                          },
                          "value": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "tokenTransfers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "token",
                    "symbol",
                    "from",
                    "to",
                    "raw",
                    "amount"
                  ],
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "symbol": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "from": {
                      "type": "string"
                    },
                    "to": {
                      "type": "string"
                    },
                    "raw": {
                      "type": "string"
                    },
                    "amount": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              },
              "graph": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "nodes",
                  "edges"
                ],
                "properties": {
                  "nodes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "kind",
                        "label"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "kind": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "edges": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "from",
                        "to",
                        "relation"
                      ],
                      "properties": {
                        "from": {
                          "type": "string"
                        },
                        "to": {
                          "type": "string"
                        },
                        "relation": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}