{
  "openapi": "3.0.0",
  "info": {
    "title": "TX Decoder",
    "version": "1.0.0",
    "description": "Decode EVM transactions, calldata, event logs and function selectors across Ethereum, Base, Arbitrum, Optimism, Polygon and BNB Smart Chain. Paid via MPP — gas abstracted, no API keys."
  },
  "servers": [{ "url": "https://txdecode.ivan-tempo.xyz" }],
  "paths": {
    "/api/decode": {
      "get": {
        "operationId": "decodeTransaction",
        "summary": "Decode a transaction by hash",
        "description": "Fetches a transaction and decodes its method, parameters, value and from/to. Uses verified ABIs when available, otherwise 4byte/openchain signature databases.",
        "parameters": [
          { "name": "tx", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Transaction hash (0x + 64 hex chars)" },
          { "name": "chain", "in": "query", "required": false, "schema": { "type": "string", "enum": ["eth", "base", "arbitrum", "optimism", "polygon", "bsc"], "default": "eth" } }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.01",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 10000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Decoded transaction" },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/decode/calldata": {
      "get": {
        "operationId": "decodeCalldata",
        "summary": "Decode raw calldata",
        "description": "Decodes an arbitrary 0x-prefixed calldata blob into function name and parameters. Optionally pass a contract address to use its verified ABI for parameter names.",
        "parameters": [
          { "name": "data", "in": "query", "required": true, "schema": { "type": "string" }, "description": "0x-prefixed calldata (at least a 4-byte selector)" },
          { "name": "to", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Target contract address (improves decode with verified ABI)" },
          { "name": "chain", "in": "query", "required": false, "schema": { "type": "string", "enum": ["eth", "base", "arbitrum", "optimism", "polygon", "bsc"], "default": "eth" } }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.01",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 10000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Decoded calldata" },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/decode/deep": {
      "get": {
        "operationId": "decodeDeep",
        "summary": "Decode a transaction plus all event logs",
        "description": "Decodes the transaction and every emitted event log (using verified ABIs or signature databases), with receipt status and gas used.",
        "parameters": [
          { "name": "tx", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Transaction hash (0x + 64 hex chars)" },
          { "name": "chain", "in": "query", "required": false, "schema": { "type": "string", "enum": ["eth", "base", "arbitrum", "optimism", "polygon", "bsc"], "default": "eth" } }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.04",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 40000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Decoded transaction with events" },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/decode/batch": {
      "get": {
        "operationId": "decodeBatch",
        "summary": "Batch decode up to 20 transactions",
        "description": "Decodes a comma-separated list of transaction hashes. Price scales at $0.01 per transaction.",
        "parameters": [
          { "name": "txs", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Comma-separated transaction hashes (max 20)" },
          { "name": "chain", "in": "query", "required": false, "schema": { "type": "string", "enum": ["eth", "base", "arbitrum", "optimism", "polygon", "bsc"], "default": "eth" } }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.01",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 10000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true,
          "priceNote": "per transaction"
        },
        "responses": {
          "200": { "description": "Array of decoded transactions" },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/abi": {
      "get": {
        "operationId": "fetchAbi",
        "summary": "Fetch a verified contract ABI",
        "description": "Returns the verified ABI for a contract address via the Etherscan v2 multichain API, with function/event counts.",
        "parameters": [
          { "name": "address", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Contract address (0x + 40 hex chars)" },
          { "name": "chain", "in": "query", "required": false, "schema": { "type": "string", "enum": ["eth", "base", "arbitrum", "optimism", "polygon", "bsc"], "default": "eth" } }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.01",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 10000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Contract ABI" },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/selector": {
      "get": {
        "operationId": "lookupSelector",
        "summary": "Lookup a function or event selector",
        "description": "Resolves a 4-byte function selector or 32-byte event topic into human-readable signatures via 4byte.directory and openchain.xyz.",
        "parameters": [
          { "name": "selector", "in": "query", "required": true, "schema": { "type": "string" }, "description": "0x-prefixed selector (e.g. 0xa9059cbb) or 32-byte event topic" }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.01",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 10000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Selector signatures" },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/simulate": {
      "get": {
        "operationId": "simulateTransaction",
        "summary": "Simulate / replay a transaction via eth_call",
        "description": "Replays a transaction against the parent block's state using eth_call, returning success/revert status, return data, and decoded revert reason.",
        "parameters": [
          { "name": "tx", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Transaction hash (0x + 64 hex chars)" },
          { "name": "chain", "in": "query", "required": false, "schema": { "type": "string", "enum": ["eth", "base", "arbitrum", "optimism", "polygon", "bsc"], "default": "eth" } }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.02",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 20000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Simulation result" },
          "402": { "description": "Payment required." }
        }
      }
    }
  }
}
