跳轉到內容

驗證訂單

接口信息

接口: POST /api/v1/orders/validate

描述: 驗證訂單的有效性(不創建訂單)

鑑權: API Key憑據認證

請求參數

字段類型必填說明
orderobject訂單信息
order.makerstring訂單創建者地址
order.principalstring接收者地址
order.is_buybool是否是買入
order.tickerstring股票代碼
order.exchangeint交易所ID
order.assetstring資產代幣地址
order.pricestring價格
order.quantitystring數量
order.incentivestring激勵金額
order.deadlinelong截止時間戳
order.noncelong防重放數字
signaturestring訂單簽名

響應參數

字段類型說明
validboolean訂單是否有效
order_hashstring訂單哈希值
errorsarray錯誤信息列表
maker_balancestringMaker餘額
maker_allowancestringMaker授權額度
nonce_validbooleannonce是否有效
signature_validboolean簽名是否有效
not_expiredboolean是否未過期

請求示例

bash
curl -X POST "/api/v1/orders/validate" \
     -H "X-API-Key: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "order": {
         "maker": "0x1234567890123456789012345678901234567890",
         "principal": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
         "is_buy": true,
         "ticker": "AAPL",
         "exchange": 0,
         "asset": "0x0000000000000000000000000000000000000001",
         "price": "150250000000000000000",
         "quantity": "100",
         "incentive": "1000000000000000000",
         "deadline": 1735689600,
         "nonce": 1
       },
       "signature": "0x..."
     }'

響應示例

json
{
    "code": 0,
    "data": {
        "valid": true,
        "order_hash": "0x1234567890abcdef...",
        "errors": [],
        "maker_balance": "10000000000000000000000",
        "maker_allowance": "5000000000000000000000",
        "nonce_valid": true,
        "signature_valid": true,
        "not_expired": true
    }
}

注意事項

  • 此接口僅驗證訂單,不會創建訂單
  • 可用於在鎖定訂單前進行預檢查
  • 驗證項包括:餘額、授權額度、nonce、簽名、過期時間等