DeFi API

生成交易前授权的调用数据#

描述:该 API 将提供你进行交易前各种授权的调用数据。

请求地址#

POST https://www.okx.com/api/v5/defi/transaction/authorization

请求参数#

参数名称相关描述参数类型必传数据类型
address用户钱包地址请求体String
investmentId投资品 ID请求体String
type交易类型 (例如,3:认购授权;4:赎回授权;5:领取授权)请求体int
userInputList用户输入代币信息请求体Array[Struct]
>chainId区块链 ID请求体String
>coinAmount认购数量请求体String
>tokenAddress认购代币的智能合约地址请求体String
expectOutputLIst用户预期收益信息请求体Array[Struct]
>chainId区块链 ID请求体String
>coinAmount认购数量请求体String
>tokenAddress认购代币的智能合约地址请求体String

响应参数#

参数名称相关描述数据类型
dataListCall date 数据信息Array[Struct]
>from发送地址 (用户地址)String
>to接受地址 (目标合约地址)String
>value转账金额 (原生代币数量,默认为空字符串)String
>serializedDataCall data 数据String
>originalData原始数据 (JSON)JSON String
>callDataType操作类型 (授权、申购、赎回、领取)String

请求示例#

shell
curl --location 'https://www.okx.com/api/v5/defi/transaction/authorization' \
--header 'OK-ACCESS-KEY: 9c****77' \
--header 'OK-ACCESS-PASSPHRASE: p****d' \
--header 'Content-Type: application/json' \
--data '{
  "address": "0x7f****da",
  "userInputList": [
    {
      "chainId": 56,
      "coinAmount": "10",
      "tokenAddress": "0x526a913a7a4518aa2abc3dcd3c46a9c73f40f94a"
    }
  ],
  "investmentId": "6925",
  "type": 3
}'

响应示例#

200
{
  "code": 0,
  "msg": "",
  "data": {
    "dataList": [
      {
        "from": "0x7f****da",
        "to": "0x52****4a",
        "value": "0x0",
        "serializedData": "0x095ea7b30000000000000000000000002c34a2fb1d0b4f55de51e1d0bdefaddce6b7cdd60000000000000000000000000000000000000000000000008ac7230489e80000",
        "originalDataClass": "OriginalDataApprove",
        "originalData": "{\"methodDefine\":\"approve(address,uint256)\",\"methodId\":\"0x095ea7b3\",\"methodType\":\"METHOD_ID\",\"params\":{\"params\":[\"0x2c34a2fb1d0b4f55de51e1d0bdefaddce6b7cdd6\",\"10000000000000000000\"]},\"useAdapter\":false}",
        "signatureData": "1bca0efbd1c809de94cdd8c924329c7ac79a4d346742de61925e8494f2c84c446bd3cf42b56d690c85ff513beadf46cd18f4e3e74845a92c48451584615f749d1c"
      }
    ]
  }
}