> ## Documentation Index
> Fetch the complete documentation index at: https://dexbuilder.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Solana ATA 檢測與構建

> 檢測 Solana ATA 並構建創建交易。

檢測 Solana ATA 並構建創建交易。

> [!NOTE]
>
> 使用 Broker API Key 呼叫，並在請求頭提供 `X-User-Wallet-Address`。網關會校驗錢包與 Broker 的歸屬關係。 認證規則見[Broker API 認證與簽名](https://dexbuilder.mintlify.site/zh-TW/api-reference/common/broker-authentication.md)。

## 使用說明

* 此介面的 `X-User-Wallet-Address` 須為 Solana 錢包地址，不應使用 EVM `0x` 地址。`payer_address` 是使用者已綁定的 Solana 錢包，承擔鏈上 rent 與手續費；`target_address` 是 ATA 所屬 owner。
* 當 `status=0` 時，須先簽名並廣播回傳的 base64 `tx_data` 再提現；當 `status=1` 時，ATA 已存在且 `tx_data` 為空。廣播失敗後可重新查詢。


## OpenAPI

````yaml openapi/dexbuilder-zh-TW.yaml POST /api/v4/dexbuilder/withdraw/ata/check-and-build
openapi: 3.0.3
info:
  title: DexBuilder 平台 Broker API
  version: 1.0.0
  description: DexBuilder 平台 Broker API，涵蓋資產配置、使用者、充值與提現能力。認證和使用者錢包校驗見本站統一網關說明。
servers:
  - url: https://api.dexbuilder.com
security: []
paths:
  /api/v4/dexbuilder/withdraw/ata/check-and-build:
    post:
      tags:
        - 提現
      summary: Solana ATA 檢測與構建
      description: 檢測目標 SPL 賬戶是否存在；不存在時回傳待簽名 base64 交易。
      operationId: dexBuilderWithdrawATACheckAndBuild
      parameters:
        - $ref: '#/components/parameters/SubUserWalletAddr'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PerpWithdrawATACheckRequest'
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvelopeWithdrawATACheck'
        '400':
          $ref: '#/components/responses/OpenAPIBadRequest'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '401':
          $ref: '#/components/responses/GatewayUnauthorized'
        '403':
          $ref: '#/components/responses/ProjectAccessDenied'
      security:
        - BrokerAPIKey: []
          Timestamp: []
          Signature: []
components:
  parameters:
    SubUserWalletAddr:
      name: X-User-Wallet-Address
      in: header
      required: true
      description: 目標終端使用者錢包地址。網關校驗該錢包對應的使用者屬於當前 Broker。
      schema:
        type: string
  schemas:
    PerpWithdrawATACheckRequest:
      type: object
      required:
        - payer_address
        - target_address
      properties:
        payer_address:
          type: string
          description: Solana 使用者錢包（base58），須為已綁定錢包
        target_address:
          type: string
          description: 待檢測 ATA 的 owner 地址（base58）
    EnvelopeWithdrawATACheck:
      allOf:
        - $ref: '#/components/schemas/EnvelopeBase'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/PerpWithdrawATACheckResponse'
    ErrorEnvelope:
      allOf:
        - $ref: '#/components/schemas/EnvelopeBase'
        - type: object
          required:
            - label
          properties:
            label:
              type: string
              description: 穩定的機器可讀錯誤標識
            data:
              nullable: true
              description: 錯誤時一般為 null
    EnvelopeBase:
      type: object
      properties:
        code:
          type: integer
          example: 0
          description: 業務碼，`0` 表示成功
        message:
          type: string
          example: success
          description: 人類可讀說明，成功時為 success
        reason:
          type: string
          description: 錯誤原因標識；成功時通常為空字符串
        trace_id:
          type: string
          description: 鏈路追蹤 ID，排障時提供
    PerpWithdrawATACheckResponse:
      type: object
      properties:
        status:
          type: integer
          description: 0=需創建 ATA；1=已存在
        tx_data:
          type: string
          description: base64 交易，status=0 時有值
  responses:
    OpenAPIBadRequest:
      description: 請求無效（參數、請求體、使用者身份或業務校驗）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            invalidArgument:
              summary: 參數無效
              value:
                label: INVALID_ARGUMENT
                message: invalid argument
            userNotFound:
              summary: 使用者不存在
              value:
                label: USER_NOT_FOUND
                message: User not found
            missingHeader:
              summary: 缺少必要請求頭
              value:
                label: MISSING_REQUIRED_HEADER
                message: invalid headers
    GatewayUnauthorized:
      description: Broker API Key、簽名或時間戳無效
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            invalidKey:
              summary: 無效 API Key
              value:
                label: INVALID_KEY
                message: Invalid key provided
                code: 401
                trace_id: abc123
            invalidSignature:
              summary: 簽名錯誤
              value:
                label: INVALID_SIGNATURE
                message: Invalid signature
                code: 401
                trace_id: abc123
    ProjectAccessDenied:
      description: 專案未綁定或 Broker/API Key 不匹配
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            code: 40300801
            reason: P_DEX_BUILDER_IN_PROJECT_ACCESS_DENIED
            label: PROJECT_ACCESS_DENIED
            message: project access denied
            data: null
  securitySchemes:
    BrokerAPIKey:
      type: apiKey
      in: header
      name: KEY
      description: Broker API Key
    Timestamp:
      type: apiKey
      in: header
      name: Timestamp
      description: Unix 秒級時間戳
    Signature:
      type: apiKey
      in: header
      name: SIGN
      description: 使用 Broker Secret Key 生成的 HMAC-SHA512 十六進制簽名

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.