{
  "openapi": "3.1.1",
  "info": {
    "title": "Wallet Permission Explorer API",
    "version": "1.0.0",
    "summary": "Who can move your tokens? Allowances, Permit2, NFT operators and EIP-7702 delegation, with risk.",
    "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://walletpermissionexplorer.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Who can move your tokens? Allowances, Permit2, NFT operators and EIP-7702 delegation, with risk.",
        "description": "Checks a wallet's live token permissions straight from the chain: ERC-20 allowances for the major tokens against a verified list of well-known spenders (Uniswap Permit2 and routers, 1inch, 0x, CoW, Aave, OpenSea), Permit2 sub-allowances with expiry, NFT operator approvals for collections you list, and EIP-7702 account delegation. Flags unlimited approvals, approvals to plain wallets and to unverified contracts, and shows how much of your balance is exposed.\n\nMethodology:\n- ERC-20: allowance(owner, spender) via eth_call for USDC/USDT/WETH/DAI (official addresses per chain) plus your extra tokens, against a list of spenders whose addresses were checked against official deployment lists and Sourcify-verified contract names (Permit2, Uniswap Universal Router / V2 / V3 routers, 1inch v5/v6, 0x Exchange Proxy / AllowanceHolder, CoW VaultRelayer, Aave V3 Pool, Seaport, OpenSea Conduit) plus your extra spenders.\n- Permit2: for tokens approved to Permit2, Permit2.allowance(owner, token, spender) returns (amount, expiration, nonce); only unexpired, non-zero sub-allowances are reported.\n- NFTs: isApprovedForAll(owner, operator) for each collection you list against Seaport, the OpenSea Conduit and your extra spenders.\n- EIP-7702: an account whose code is 0xef0100‖address is delegated to that address's code.\n- Risk: unlimited = allowance ≥ 2^255 (ERC-20) or ≥ 2^159 (Permit2 uint160); spenders without code (EOAs) or without verified source are high risk; NFT operator approvals always carry at least medium risk.\n- Exposure = min(allowance, current balance) × current DefiLlama USD price. Offline mode replays Approval/ApprovalForAll logs (latest value per token+spender wins, current values override).",
        "tags": [
          "web3"
        ],
        "x-mcp-tool": "wallet_permission_explorer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WalletPermissionExplorerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Approval history of a wallet (offline)",
                  "value": {
                    "mode": "logs",
                    "chain": "ethereum",
                    "owner": "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed",
                    "approvalLogs": "[{\"address\":\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\"topics\":[\"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925\",\"0x0000000000000000000000005aaeb6053f3e94c9b9a09f33669435e7ef1beaed\",\"0x000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3\"],\"data\":\"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\",\"blockNumber\":\"0x1300000\",\"logIndex\":\"0x1\"},{\"address\":\"0xdac17f958d2ee523a2206206994597c13d831ec7\",\"topics\":[\"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925\",\"0x0000000000000000000000005aaeb6053f3e94c9b9a09f33669435e7ef1beaed\",\"0x0000000000000000000000009999999999999999999999999999999999999999\"],\"data\":\"0x000000000000000000000000000000000000000000000000000000012a05f200\",\"blockNumber\":\"0x1300100\",\"logIndex\":\"0x4\"},{\"address\":\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\"topics\":[\"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925\",\"0x0000000000000000000000005aaeb6053f3e94c9b9a09f33669435e7ef1beaed\",\"0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d\"],\"data\":\"0x0000000000000000000000000000000000000000000000001bc16d674ec80000\",\"blockNumber\":\"0x1300200\",\"logIndex\":\"0x0\"},{\"address\":\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\"topics\":[\"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925\",\"0x0000000000000000000000005aaeb6053f3e94c9b9a09f33669435e7ef1beaed\",\"0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d\"],\"data\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"blockNumber\":\"0x1300300\",\"logIndex\":\"0x2\"},{\"address\":\"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d\",\"topics\":[\"0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31\",\"0x0000000000000000000000005aaeb6053f3e94c9b9a09f33669435e7ef1beaed\",\"0x0000000000000000000000001e0049783f008a0085193e00003d00cd54003c71\"],\"data\":\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"blockNumber\":\"0x1300400\",\"logIndex\":\"0x7\"}]",
                    "currentAllowances": "[{\"token\":\"0xdac17f958d2ee523a2206206994597c13d831ec7\",\"spender\":\"0x9999999999999999999999999999999999999999\",\"allowance\":\"1500000000\"}]"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WalletPermissionExplorerResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "WalletPermissionExplorerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "What do you have?",
            "type": "string",
            "enum": [
              "lookup",
              "logs"
            ],
            "default": "lookup"
          },
          "chain": {
            "title": "Chain",
            "type": "string",
            "enum": [
              "ethereum",
              "base",
              "arbitrum",
              "optimism",
              "polygon",
              "avalanche",
              "bsc"
            ],
            "default": "ethereum"
          },
          "owner": {
            "title": "Wallet address (owner)",
            "type": "string",
            "maxLength": 42
          },
          "extraTokens": {
            "title": "Extra ERC-20 tokens to check",
            "description": "One token address per line (added to USDC/USDT/WETH/DAI on this chain).",
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 15
          },
          "extraSpenders": {
            "title": "Extra spenders / operators to check",
            "description": "One address per line, e.g. a contract you once approved.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 15
          },
          "nftCollections": {
            "title": "NFT collections (ERC-721/1155) to check",
            "description": "One collection address per line; checked with isApprovedForAll against marketplace operators and your extra spenders.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 10
          },
          "approvalLogs": {
            "title": "Approval / ApprovalForAll logs JSON (offline)",
            "description": "Array of {address, topics, data, blockNumber?, logIndex?} as returned by eth_getLogs.",
            "type": "string",
            "maxLength": 500000
          },
          "currentAllowances": {
            "title": "Current allowance values JSON (offline, optional)",
            "description": "Array of {token, spender, allowance} overriding the log values (e.g. after partial spending).",
            "type": "string",
            "maxLength": 100000
          }
        },
        "required": []
      },
      "WalletPermissionExplorerResult": {
        "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",
              "owner",
              "account",
              "approvals",
              "counts",
              "checked",
              "exposureUsd",
              "graph"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "lookup",
                  "logs"
                ]
              },
              "chain": {
                "type": "string"
              },
              "owner": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "account": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "type",
                  "delegate",
                  "delegateName",
                  "delegateVerified"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "eoa",
                      "contract",
                      "eip7702-delegated"
                    ]
                  },
                  "delegate": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "delegateName": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "delegateVerified": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  }
                }
              },
              "approvals": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "kind",
                    "token",
                    "tokenLabel",
                    "spender",
                    "spenderLabel",
                    "spenderType",
                    "amountRaw",
                    "amount",
                    "unlimited",
                    "expiration",
                    "balance",
                    "exposure",
                    "exposureUsd",
                    "risk",
                    "reasons"
                  ],
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "erc20",
                        "permit2",
                        "nft-operator"
                      ]
                    },
                    "token": {
                      "type": "string"
                    },
                    "tokenLabel": {
                      "type": "string"
                    },
                    "spender": {
                      "type": "string"
                    },
                    "spenderLabel": {
                      "type": "string"
                    },
                    "spenderType": {
                      "type": "string",
                      "enum": [
                        "known",
                        "eoa",
                        "eip7702-account",
                        "verified-contract",
                        "unverified-contract",
                        "unknown"
                      ]
                    },
                    "amountRaw": {
                      "type": "string"
                    },
                    "amount": {
                      "type": "string"
                    },
                    "unlimited": {
                      "type": "boolean"
                    },
                    "expiration": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "balance": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "exposure": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "exposureUsd": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "risk": {
                      "type": "string",
                      "enum": [
                        "high",
                        "medium",
                        "low"
                      ]
                    },
                    "reasons": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "counts": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "active",
                  "unlimited",
                  "high",
                  "medium",
                  "low",
                  "revokedInLogs"
                ],
                "properties": {
                  "active": {
                    "type": "integer"
                  },
                  "unlimited": {
                    "type": "integer"
                  },
                  "high": {
                    "type": "integer"
                  },
                  "medium": {
                    "type": "integer"
                  },
                  "low": {
                    "type": "integer"
                  },
                  "revokedInLogs": {
                    "type": "integer"
                  }
                }
              },
              "checked": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "tokens",
                  "spenders",
                  "pairs",
                  "collections"
                ],
                "properties": {
                  "tokens": {
                    "type": "integer"
                  },
                  "spenders": {
                    "type": "integer"
                  },
                  "pairs": {
                    "type": "integer"
                  },
                  "collections": {
                    "type": "integer"
                  }
                }
              },
              "exposureUsd": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "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"
              }
            }
          }
        }
      }
    }
  }
}