{
  "openapi": "3.1.1",
  "info": {
    "title": "Rollup Batch Explorer API",
    "version": "1.0.0",
    "summary": "How L2 transactions reach Ethereum: unsafe → safe → finalized, blobs, batch costs, withdrawal waits.",
    "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://rollupbatchexplorer.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "How L2 transactions reach Ethereum: unsafe → safe → finalized, blobs, batch costs, withdrawal waits.",
        "description": "For a Base, OP Mainnet or Arbitrum One transaction or block, shows whether it is only sequencer-confirmed (unsafe), already posted to Ethereum in a batch (safe) or settled on finalized Ethereum data (finalized) — and, for Arbitrum, the batch number that contains it. It also scans the latest Ethereum blocks for rollup batch transactions (OP Stack batch inboxes and the Arbitrum SequencerInbox), counting blobs, blob gas and the fee each batch paid, and explains the documented withdrawal windows.\n\nMethodology:\n- L2 status: the L2 node's \"safe\" and \"finalized\" block tags. OP Stack: safe = derived from batch data already included on L1; finalized = derived from finalized L1 blocks. Arbitrum Nitro maps the same tags to batches posted in safe/finalized L1 blocks. Blocks above the safe head are \"unsafe\" (sequencer-confirmed only).\n- Arbitrum: NodeInterface (0x…C8).findBatchContainingBlock(block) gives the batch number once the block is posted.\n- L1 batches: transactions in the last N Ethereum blocks sent to the Base batch inbox (0xff…8453), the OP Mainnet batch inbox (0xff…0010) or the Arbitrum SequencerInbox; OP Stack batches are only valid when sent by the chain's authorised batcher, which is checked. Arbitrum batch numbers come from SequencerBatchDelivered logs.\n- Cost per batch = gasUsed × effectiveGasPrice + blobGasUsed × blobGasPrice from the transaction receipt; blob count = blobVersionedHashes of the type-3 transaction.\n- Withdrawal windows are quoted from each rollup's documentation (linked as sources); they apply to L2→L1 withdrawals, not to ordinary L2 transactions.",
        "tags": [
          "web3"
        ],
        "x-mcp-tool": "rollup_batch_explorer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RollupBatchExplorerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Ethereum block with a Base and an Arbitrum batch (offline)",
                  "value": {
                    "mode": "pasted",
                    "rollup": "base",
                    "l1BlockJson": "{\"number\":\"0x1481060\",\"timestamp\":\"0x675abd80\",\"baseFeePerGas\":\"0x1dcd65000\",\"blobGasUsed\":\"0x120000\",\"excessBlobGas\":\"0x0\",\"transactions\":[{\"hash\":\"0xb1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1\",\"blockNumber\":\"0x1481060\",\"from\":\"0x5050f69a9786f081509234f1a7f4684b5e5b76c9\",\"to\":\"0xff00000000000000000000000000000000008453\",\"type\":\"0x3\",\"input\":\"0x\",\"gasPrice\":\"0x218711a00\",\"blobVersionedHashes\":[\"0x0100000000000000000000000000000000000000000000000000000000000000\",\"0x0100000000000000000000000000000000000000000000000000000000000001\",\"0x0100000000000000000000000000000000000000000000000000000000000002\",\"0x0100000000000000000000000000000000000000000000000000000000000003\",\"0x0100000000000000000000000000000000000000000000000000000000000004\",\"0x0100000000000000000000000000000000000000000000000000000000000005\"]},{\"hash\":\"0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1\",\"blockNumber\":\"0x1481060\",\"from\":\"0xc1b634853cb333d3ad8663715b08f41a3aec47cc\",\"to\":\"0x1c479675ad559dc151f6ec7ed3fbf8cee79582b6\",\"type\":\"0x3\",\"input\":\"0x3e5aa08200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"gasPrice\":\"0x218711a00\",\"blobVersionedHashes\":[\"0x0100000000000000000000000000000000000000000000000000000000000006\",\"0x0100000000000000000000000000000000000000000000000000000000000007\",\"0x0100000000000000000000000000000000000000000000000000000000000008\"]},{\"hash\":\"0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"blockNumber\":\"0x1481060\",\"from\":\"0x1111111111111111111111111111111111111111\",\"to\":\"0x2222222222222222222222222222222222222222\",\"type\":\"0x2\",\"input\":\"0x\",\"gasPrice\":\"0x218711a00\"}],\"receipts\":[{\"transactionHash\":\"0xb1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1\",\"gasUsed\":\"0x5208\",\"effectiveGasPrice\":\"0x218711a00\",\"blobGasUsed\":\"0xc0000\",\"blobGasPrice\":\"0xf4240\",\"logs\":[]},{\"transactionHash\":\"0xa1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1\",\"gasUsed\":\"0x29810\",\"effectiveGasPrice\":\"0x218711a00\",\"blobGasUsed\":\"0x60000\",\"blobGasPrice\":\"0xf4240\",\"logs\":[{\"address\":\"0x1c479675ad559dc151f6ec7ed3fbf8cee79582b6\",\"topics\":[\"0x7394f4a19a13c7b92b5bb71033245305946ef78452f7b4986ac1390b5df4ebd7\",\"0x000000000000000000000000000000000000000000000000000000000014b32c\",\"0x1111111111111111111111111111111111111111111111111111111111111111\",\"0x2222222222222222222222222222222222222222222222222222222222222222\"],\"data\":\"0x\"}]}]}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RollupBatchExplorerResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "RollupBatchExplorerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "What do you have?",
            "type": "string",
            "enum": [
              "lookup",
              "pasted"
            ],
            "default": "lookup"
          },
          "rollup": {
            "title": "Rollup",
            "type": "string",
            "enum": [
              "base",
              "optimism",
              "arbitrum"
            ],
            "default": "base"
          },
          "l2Tx": {
            "title": "L2 transaction hash (optional)",
            "type": "string",
            "maxLength": 66
          },
          "l2Block": {
            "title": "L2 block number (optional)",
            "description": "Used when no transaction hash is given; defaults to the latest block.",
            "type": "string",
            "maxLength": 20
          },
          "l1Blocks": {
            "title": "Recent Ethereum blocks to scan for batches",
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 5
          },
          "l1BlockJson": {
            "title": "L1 block JSON (offline)",
            "description": "eth_getBlockByNumber(…, true) result (or an array of them), optionally with a \"receipts\" array for exact costs.",
            "type": "string",
            "maxLength": 3000000
          }
        },
        "required": []
      },
      "RollupBatchExplorerResult": {
        "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",
              "rollup",
              "l2",
              "l1Scan",
              "batches",
              "perRollup",
              "windows",
              "graph"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "lookup",
                  "pasted"
                ]
              },
              "rollup": {
                "type": "string"
              },
              "l2": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "chain",
                  "block",
                  "txHash",
                  "timestamp",
                  "status",
                  "latest",
                  "safe",
                  "finalized",
                  "arbitrumBatch"
                ],
                "properties": {
                  "chain": {
                    "type": "string"
                  },
                  "block": {
                    "type": "integer"
                  },
                  "txHash": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "timestamp": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "unsafe",
                      "safe",
                      "finalized"
                    ]
                  },
                  "latest": {
                    "type": "integer"
                  },
                  "safe": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "finalized": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "arbitrumBatch": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "l1Scan": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "fromBlock",
                  "toBlock",
                  "blocksScanned"
                ],
                "properties": {
                  "fromBlock": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "toBlock": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "blocksScanned": {
                    "type": "integer"
                  }
                }
              },
              "batches": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "l1Block",
                    "l1Time",
                    "txHash",
                    "rollup",
                    "from",
                    "authorized",
                    "type",
                    "blobs",
                    "blobGasUsed",
                    "blobGasPriceWei",
                    "executionFeeWei",
                    "blobFeeWei",
                    "totalFeeEth",
                    "calldataBytes",
                    "arbitrumBatch"
                  ],
                  "properties": {
                    "l1Block": {
                      "type": "integer"
                    },
                    "l1Time": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "txHash": {
                      "type": "string"
                    },
                    "rollup": {
                      "type": "string"
                    },
                    "from": {
                      "type": "string"
                    },
                    "authorized": {
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "type": {
                      "type": "integer"
                    },
                    "blobs": {
                      "type": "integer"
                    },
                    "blobGasUsed": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "blobGasPriceWei": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "executionFeeWei": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "blobFeeWei": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "totalFeeEth": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "calldataBytes": {
                      "type": "integer"
                    },
                    "arbitrumBatch": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  }
                }
              },
              "perRollup": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "rollup",
                    "batches",
                    "blobs",
                    "blobGasUsed",
                    "totalFeeEth"
                  ],
                  "properties": {
                    "rollup": {
                      "type": "string"
                    },
                    "batches": {
                      "type": "integer"
                    },
                    "blobs": {
                      "type": "integer"
                    },
                    "blobGasUsed": {
                      "type": "string"
                    },
                    "totalFeeEth": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              },
              "windows": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "rollup",
                    "fact",
                    "source"
                  ],
                  "properties": {
                    "rollup": {
                      "type": "string"
                    },
                    "fact": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              },
              "graph": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "nodes",
                  "edges"
                ],
                "properties": {
                  "nodes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "label",
                        "kind"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        },
                        "kind": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "edges": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "from",
                        "to",
                        "label"
                      ],
                      "properties": {
                        "from": {
                          "type": "string"
                        },
                        "to": {
                          "type": "string"
                        },
                        "label": {
                          "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"
              }
            }
          }
        }
      }
    }
  }
}