{
 "openapi": "3.1.0",
 "info": {
  "title": "x402 Ethereum Tx Tools",
  "version": "1.2.0",
  "description": "Pay-per-call Ethereum mainnet tools: simulate a tx or bundle, pre-sign safety check, explain a mined tx, broadcast a signed tx (Flashbots Protect or public mempool). USDC on Base via x402.",
  "x-guidance": "POST /simulate {from,to,data,value} or {calls:[...]}; POST /check with the same plus optional typedData (EIP-712) or authorizationList (EIP-7702) for risk flags and a verdict; POST /explain {hash} for a mined tx; POST /execute {rawTx} to broadcast a tx you already signed (chainId 1), private via Flashbots by default. Unpaid requests return 402; pay with any x402 client and retry. Charged only on success. Full docs: /llms-full.txt"
 },
 "servers": [
  {
   "url": "https://sim.0xrelay.party"
  }
 ],
 "x-discovery": {
  "llms": "https://sim.0xrelay.party/llms.txt",
  "wellKnown": "https://sim.0xrelay.party/.well-known/x402"
 },
 "paths": {
  "/simulate": {
   "post": {
    "operationId": "simulate",
    "summary": "Simulate an Ethereum mainnet transaction or bundle",
    "x-payment-info": {
     "protocols": [
      {
       "x402": {}
      }
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.002"
     },
     "network": "base",
     "asset": "USDC",
     "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
     "x402Versions": [
      1,
      2
     ]
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/Call"
         },
         {
          "type": "object",
          "required": [
           "calls"
          ],
          "additionalProperties": false,
          "properties": {
           "calls": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "items": {
             "$ref": "#/components/schemas/Call"
            }
           },
           "block": {
            "oneOf": [
             {
              "type": "string"
             },
             {
              "type": "integer"
             }
            ]
           }
          }
         }
        ]
       },
       "example": {
        "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
        "to": "0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "data": "0xa9059cbb000000000000000000000000ef4396d9ff8107086d215a1c9f8866c54795d7c700000000000000000000000000000000000000000000000000000000000f4240"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Simulation result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Result"
        }
       }
      }
     },
     "400": {
      "description": "Invalid input"
     },
     "402": {
      "description": "Payment required (x402 v1 body, v2 PAYMENT-REQUIRED header)"
     },
     "429": {
      "description": "Rate limited"
     },
     "502": {
      "description": "Upstream error, not charged"
     },
     "504": {
      "description": "Timeout, not charged"
     }
    }
   }
  },
  "/health": {
   "get": {
    "operationId": "health",
    "summary": "Free status and current block",
    "responses": {
     "200": {
      "description": "OK"
     }
    },
    "security": []
   }
  },
  "/check": {
   "post": {
    "operationId": "check",
    "summary": "Pre-sign safety check: risk flags and verdict for a tx, bundle or EIP-712 signature",
    "x-payment-info": {
     "protocols": [
      {
       "x402": {}
      }
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.003"
     },
     "network": "base",
     "asset": "USDC",
     "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
     "x402Versions": [
      1,
      2
     ]
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "from": {
          "type": "string"
         },
         "to": {
          "type": "string"
         },
         "data": {
          "type": "string"
         },
         "value": {
          "type": [
           "string",
           "integer"
          ]
         },
         "calls": {
          "type": "array",
          "maxItems": 8,
          "items": {
           "$ref": "#/components/schemas/Call"
          }
         },
         "typedData": {
          "type": "object",
          "description": "EIP-712 payload (Permit, Permit2, Seaport, ...)"
         },
         "authorizationList": {
          "type": "array",
          "maxItems": 8,
          "items": {
           "type": "object",
           "required": [
            "address"
           ],
           "properties": {
            "address": {
             "type": "string"
            }
           }
          }
         }
        }
       },
       "example": {
        "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
        "to": "0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "data": "0x095ea7b3000000000000000000000000ef4396d9ff8107086d215a1c9f8866c54795d7c7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Verdict",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "verdict": {
           "type": "string",
           "enum": [
            "ok",
            "warn",
            "danger"
           ]
          },
          "summary": {
           "type": "string"
          },
          "flags": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "severity": {
              "type": "string",
              "enum": [
               "info",
               "warn",
               "danger"
              ]
             },
             "kind": {
              "type": "string"
             },
             "message": {
              "type": "string"
             }
            }
           }
          },
          "simulation": {
           "$ref": "#/components/schemas/Result"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Invalid input"
     },
     "402": {
      "description": "Payment required (x402 v1 body, v2 PAYMENT-REQUIRED header)"
     },
     "429": {
      "description": "Rate limited"
     },
     "502": {
      "description": "Upstream error, not charged"
     },
     "504": {
      "description": "Timeout, not charged"
     }
    }
   }
  },
  "/explain": {
   "post": {
    "operationId": "explain",
    "summary": "Explain a mined Ethereum mainnet tx: call tree, transfers, balance changes, fee",
    "x-payment-info": {
     "protocols": [
      {
       "x402": {}
      }
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.002"
     },
     "network": "base",
     "asset": "USDC",
     "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
     "x402Versions": [
      1,
      2
     ]
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "hash"
        ],
        "additionalProperties": false,
        "properties": {
         "hash": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{64}$"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Decoded tx",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "tx": {
           "type": "object"
          },
          "status": {
           "type": "string",
           "enum": [
            "success",
            "reverted"
           ]
          },
          "revertReason": {
           "type": [
            "string",
            "null"
           ]
          },
          "fee": {
           "type": "object"
          },
          "balanceChanges": {
           "type": "array"
          },
          "tokenTransfers": {
           "type": "array"
          },
          "internalEth": {
           "type": "array"
          },
          "logs": {
           "type": "array"
          },
          "callTree": {
           "type": "object"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Unknown or pending hash (free, checked before payment)"
     },
     "400": {
      "description": "Invalid input"
     },
     "402": {
      "description": "Payment required (x402 v1 body, v2 PAYMENT-REQUIRED header)"
     },
     "429": {
      "description": "Rate limited"
     },
     "502": {
      "description": "Upstream error, not charged"
     },
     "504": {
      "description": "Timeout, not charged"
     }
    }
   }
  },
  "/execute": {
   "post": {
    "operationId": "execute",
    "summary": "Broadcast a client-signed Ethereum mainnet tx via Flashbots Protect (default) or the public mempool",
    "description": "Never signs and holds no keys: you send the signed raw tx. Before sending, the tx is decoded, its signature recovered, chainId must be 1, nonce/base fee/balance are checked against the chain and it is simulated. A reverting tx is refused unless allowRevert is true. Refusals (400/422/502/504) are not charged.",
    "x-payment-info": {
     "protocols": [
      {
       "x402": {}
      }
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.003"
     },
     "network": "base",
     "asset": "USDC",
     "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
     "x402Versions": [
      1,
      2
     ]
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "rawTx"
        ],
        "additionalProperties": false,
        "properties": {
         "rawTx": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]+$",
          "description": "EIP-2718 signed tx: legacy with EIP-155, type 1 or type 2. Types 3 (blob) and 4 (7702) are refused."
         },
         "via": {
          "type": "string",
          "enum": [
           "flashbots",
           "public"
          ],
          "default": "flashbots"
         },
         "allowRevert": {
          "type": "boolean",
          "default": false
         },
         "wait": {
          "type": "boolean",
          "default": false,
          "description": "wait up to ~10 s for the receipt"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Sent",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "hash": {
           "type": "string"
          },
          "status": {
           "type": "string",
           "enum": [
            "submitted",
            "pending",
            "mined",
            "reverted"
           ]
          },
          "via": {
           "type": "string"
          },
          "alreadyKnown": {
           "type": "boolean"
          },
          "tx": {
           "type": "object"
          },
          "simulation": {
           "type": "object"
          },
          "receipt": {
           "type": [
            "object",
            "null"
           ]
          },
          "explorer": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Invalid or non-mainnet tx"
     },
     "402": {
      "description": "Payment required (x402 v1 body, v2 PAYMENT-REQUIRED header)"
     },
     "422": {
      "description": "Not includable (nonce, fee, balance) or simulation reverts; not sent, not charged"
     },
     "429": {
      "description": "Rate limited"
     },
     "502": {
      "description": "Node error or relay rejected the tx, not charged"
     },
     "504": {
      "description": "Timeout, not charged"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Call": {
    "type": "object",
    "required": [
     "from"
    ],
    "additionalProperties": false,
    "properties": {
     "from": {
      "type": "string",
      "pattern": "^0x[0-9a-fA-F]{40}$"
     },
     "to": {
      "type": "string",
      "pattern": "^0x[0-9a-fA-F]{40}$"
     },
     "data": {
      "type": "string",
      "pattern": "^0x[0-9a-fA-F]*$"
     },
     "value": {
      "oneOf": [
       {
        "type": "string"
       },
       {
        "type": "integer"
       }
      ],
      "description": "wei"
     },
     "gas": {
      "oneOf": [
       {
        "type": "string"
       },
       {
        "type": "integer"
       }
      ],
      "description": "max 30000000"
     },
     "block": {
      "oneOf": [
       {
        "type": "string"
       },
       {
        "type": "integer"
       }
      ],
      "description": "block number or latest"
     }
    }
   },
   "Result": {
    "type": "object",
    "properties": {
     "block": {
      "type": "object"
     },
     "success": {
      "type": "boolean"
     },
     "calls": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "success": {
         "type": "boolean"
        },
        "revertReason": {
         "type": [
          "string",
          "null"
         ]
        },
        "gasUsed": {
         "type": "integer"
        },
        "returnData": {
         "type": "string"
        },
        "logs": {
         "type": "array"
        },
        "trace": {
         "type": "object"
        }
       }
      }
     },
     "balanceChanges": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "holder": {
         "type": "string"
        },
        "token": {
         "type": "string"
        },
        "symbol": {
         "type": [
          "string",
          "null"
         ]
        },
        "delta": {
         "type": "string"
        },
        "formatted": {
         "type": [
          "string",
          "null"
         ]
        }
       }
      }
     }
    }
   }
  }
 }
}