生成交易前授权的调用数据#
描述:该 API 将提供你进行交易前各种授权的调用数据。
请求地址#
POST https://web3.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 | 
响应参数#
| 参数名称 | 相关描述 | 数据类型 | 
|---|---|---|
| dataList | Call date 数据信息 | Array[Struct] | 
| >from | 发送地址 (用户地址) | String | 
| >to | 接受地址 (目标合约地址) | String | 
| >value | 转账金额 (原生代币数量,默认为空字符串) | String | 
| >serializedData | Call data 数据 | String | 
| >originalData | 原始数据 (JSON) | JSON String | 
| >callDataType | 操作类型 (授权、申购、赎回、领取) | String | 
请求示例#
shell
curl --location 'https://web3.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"
      }
    ]
  }
}
