{
  "openapi": "3.0.3",
  "info": {
    "title": "Wallet Doctor x402",
    "version": "0.6.6",
    "description": "Solana wallet & token checks: balance, txtrace, approvals, token-safety, drain triage. Pay per call in USDC on Base or Solana via PayAI (x402 v2)."
  },
  "servers": [
    {
      "url": "https://wallet-doctor-x402.m-zikriz.workers.dev"
    }
  ],
  "paths": {
    "/v1/balance": {
      "get": {
        "summary": "Solana wallet balance",
        "description": "Solana wallet balance: SOL and USDC (Solana public RPC). Pay per call in USDC on Base or Solana via x402 v2 (PayAI facilitator); settled only if the call succeeds.",
        "operationId": "v1_balance",
        "parameters": [
          {
            "name": "wallet",
            "in": "query",
            "required": true,
            "description": "Solana wallet address (base58 public key)",
            "schema": {
              "type": "string",
              "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
            },
            "example": "4dX3VmkGFJHj1XZbWN1MbRYnCaxYWEEN21LjkmCe9JRE"
          }
        ],
        "responses": {
          "200": {
            "description": "Paid response (only after x402 settlement).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "wallet": {
                      "type": "string"
                    },
                    "sol": {
                      "type": "number",
                      "description": "SOL balance"
                    },
                    "usdc": {
                      "type": "number",
                      "description": "USDC balance (all USDC token accounts)"
                    },
                    "slot": {
                      "type": "integer"
                    },
                    "network": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true,
                  "wallet": "4dX3VmkGFJHj1XZbWN1MbRYnCaxYWEEN21LjkmCe9JRE",
                  "sol": 0.0123,
                  "usdc": 1.5,
                  "slot": 468573834,
                  "network": "solana-mainnet",
                  "source": "solana-rpc"
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Body/headers carry x402 challenge with accepts[].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.0001"
          },
          "priceAtomic": {
            "USDC": "100"
          },
          "acceptsNetworks": [
            "eip155:8453",
            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
          ],
          "facilitator": "https://facilitator.payai.network"
        }
      }
    },
    "/v1/txtrace": {
      "get": {
        "summary": "Solana transaction trace",
        "description": "Solana transaction trace: status, slot, fee, SOL balance changes, first 20 log lines. Pay per call in USDC on Base or Solana via x402 v2 (PayAI facilitator); settled only if the call succeeds.",
        "operationId": "v1_txtrace",
        "parameters": [
          {
            "name": "signature",
            "in": "query",
            "required": true,
            "description": "Solana transaction signature (base58)",
            "schema": {
              "type": "string",
              "pattern": "^[1-9A-HJ-NP-Za-km-z]{64,90}$"
            },
            "example": "2b96kfbbxdTUSVLFeRWVGoUmHR1rkgni4zR2rjxzBKo929CBP8kTSP3ns9iDk58Dncnt9Fqarq68UcYFGgBwEANY"
          }
        ],
        "responses": {
          "200": {
            "description": "Paid response (only after x402 settlement).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "signature": {
                      "type": "string"
                    },
                    "slot": {
                      "type": "integer"
                    },
                    "blockTime": {
                      "type": "integer"
                    },
                    "fee_sol": {
                      "type": "number"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "err"
                      ]
                    },
                    "sol_balance_changes": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "logs_first_20": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true,
                  "signature": "2b96kfbbxdTUSVLFeRWVGoUmHR1rkgni4zR2rjxzBKo929CBP8kTSP3ns9iDk58Dncnt9Fqarq68UcYFGgBwEANY",
                  "slot": 468573834,
                  "blockTime": 1794496949,
                  "fee_sol": 0.000005,
                  "status": "ok",
                  "err": null,
                  "sol_balance_changes": [
                    {
                      "account": "4dX3VmkGFJHj1XZbWN1MbRYnCaxYWEEN21LjkmCe9JRE",
                      "delta_sol": -0.000005
                    }
                  ],
                  "logs_first_20": [
                    "Program 11111111111111111111111111111111 invoke [1]"
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Body/headers carry x402 challenge with accepts[].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.0005"
          },
          "priceAtomic": {
            "USDC": "500"
          },
          "acceptsNetworks": [
            "eip155:8453",
            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
          ],
          "facilitator": "https://facilitator.payai.network"
        }
      }
    },
    "/v1/approvals": {
      "get": {
        "summary": "SPL token approvals",
        "description": "SPL token approvals: token accounts with an active delegate (SPL Token + Token-2022). Pay per call in USDC on Base or Solana via x402 v2 (PayAI facilitator); settled only if the call succeeds.",
        "operationId": "v1_approvals",
        "parameters": [
          {
            "name": "wallet",
            "in": "query",
            "required": true,
            "description": "Solana wallet address (base58 public key)",
            "schema": {
              "type": "string",
              "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
            },
            "example": "4dX3VmkGFJHj1XZbWN1MbRYnCaxYWEEN21LjkmCe9JRE"
          }
        ],
        "responses": {
          "200": {
            "description": "Paid response (only after x402 settlement).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "wallet": {
                      "type": "string"
                    },
                    "approvals_count": {
                      "type": "integer"
                    },
                    "approvals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "token_account": {
                            "type": "string"
                          },
                          "mint": {
                            "type": "string"
                          },
                          "delegate": {
                            "type": "string"
                          },
                          "delegated_amount": {
                            "type": "string"
                          },
                          "balance": {
                            "type": "string"
                          },
                          "program": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true,
                  "wallet": "4dX3VmkGFJHj1XZbWN1MbRYnCaxYWEEN21LjkmCe9JRE",
                  "approvals_count": 0,
                  "approvals": [],
                  "source": "solana-rpc"
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Body/headers carry x402 challenge with accepts[].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.0005"
          },
          "priceAtomic": {
            "USDC": "500"
          },
          "acceptsNetworks": [
            "eip155:8453",
            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
          ],
          "facilitator": "https://facilitator.payai.network"
        }
      }
    },
    "/v1/token_safety": {
      "get": {
        "summary": "Token mint safety",
        "description": "Token mint safety: mint/freeze authority, supply, decimals; top-10 holder concentration when the public RPC allows it. Pay per call in USDC on Base or Solana via x402 v2 (PayAI facilitator); settled only if the call succeeds.",
        "operationId": "v1_token_safety",
        "parameters": [
          {
            "name": "mint",
            "in": "query",
            "required": true,
            "description": "SPL token mint address (base58)",
            "schema": {
              "type": "string",
              "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
            },
            "example": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
          }
        ],
        "responses": {
          "200": {
            "description": "Paid response (only after x402 settlement).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "mint": {
                      "type": "string"
                    },
                    "program": {
                      "type": "string"
                    },
                    "decimals": {
                      "type": "integer"
                    },
                    "supply": {
                      "type": "string"
                    },
                    "mint_authority": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "freeze_authority": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "top10_pct_of_supply": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true,
                  "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                  "program": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
                  "decimals": 6,
                  "supply": "8301066108.143972",
                  "mint_authority": "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG",
                  "freeze_authority": "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar",
                  "top10_pct_of_supply": null,
                  "flags": [
                    "mint authority active (supply can be increased)",
                    "freeze authority active (accounts can be frozen)"
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Body/headers carry x402 challenge with accepts[].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.001"
          },
          "priceAtomic": {
            "USDC": "1000"
          },
          "acceptsNetworks": [
            "eip155:8453",
            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
          ],
          "facilitator": "https://facilitator.payai.network"
        }
      }
    },
    "/v1/drain_forensics": {
      "get": {
        "summary": "Wallet activity review",
        "description": "Wallet activity review: last 25 transactions with status, failed txs flagged, plus current token delegates (for drain triage). Pay per call in USDC on Base or Solana via x402 v2 (PayAI facilitator); settled only if the call succeeds.",
        "operationId": "v1_drain_forensics",
        "parameters": [
          {
            "name": "wallet",
            "in": "query",
            "required": true,
            "description": "Solana wallet address (base58 public key)",
            "schema": {
              "type": "string",
              "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
            },
            "example": "4dX3VmkGFJHj1XZbWN1MbRYnCaxYWEEN21LjkmCe9JRE"
          }
        ],
        "responses": {
          "200": {
            "description": "Paid response (only after x402 settlement).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "wallet": {
                      "type": "string"
                    },
                    "recent_transactions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "signature": {
                            "type": "string"
                          },
                          "blockTime": {
                            "type": "integer"
                          },
                          "status": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "failed_count": {
                      "type": "integer"
                    },
                    "active_delegates": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "note": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true,
                  "wallet": "4dX3VmkGFJHj1XZbWN1MbRYnCaxYWEEN21LjkmCe9JRE",
                  "recent_transactions": [
                    {
                      "signature": "2b96kfbbxdTUSVLFeRWVGoUmHR1rkgni4zR2rjxzBKo929CBP8kTSP3ns9iDk58Dncnt9Fqarq68UcYFGgBwEANY",
                      "blockTime": 1794496949,
                      "status": "ok"
                    }
                  ],
                  "failed_count": 0,
                  "active_delegates": [],
                  "note": "Active delegates can move the delegated tokens; revoke any you do not recognise."
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Body/headers carry x402 challenge with accepts[].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.0025"
          },
          "priceAtomic": {
            "USDC": "2500"
          },
          "acceptsNetworks": [
            "eip155:8453",
            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
          ],
          "facilitator": "https://facilitator.payai.network"
        }
      }
    }
  },
  "components": {},
  "x-discovery": {
    "ownershipProofs": [
      "5ukK2Z4qF2MwNSCQpnBDCXuuiFatAC9wn9cWz41famqg",
      "0x7Dc83a4a626459e0ACB309C86dC0fEE0cC5052FC"
    ]
  }
}