DeFi API
Generate call data for transaction authorization

Generate call data for transaction authorization#

Description: This API provides you with call data for various authorizations before making a transaction.

Requset URL#

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

Request parameter#

Parameter nameDescriptionLocationRequiredData type
addressUser wallet addressRequest bodyYesString
investmentIdInvestment IDRequest bodyYesString
typeTransaction type (e.g., 3: Subscription authorization; 4: Redemption authorization; 5: Claim authorization)Request bodyYesint
userInputListUser input token informationRequest bodyYesArray[Struct]
> chainIdBlockchain IDRequest bodyNoString
> coinAmountSubscription amountRequest bodyYesString
> tokenAddressSmart contract address of the subscription tokenRequest bodyNoString
expectOutputListUser expected profit informationRequest bodyNoArray[Struct]
> chainIdBlockchain IDRequest bodyNoString
> coinAmountSubscription amountRequest bodyNoString
> tokenAddressSmart contract address of the subscription tokenRequest bodyNoString

Response parameters#

Parameter nameDescriptionData type
dataListCall data informationArray[Struct]
> fromFrom (user address)String
> toTo (target contract address)String
> valueTransfer amount (native token quantity, default is an empty string)String
> serializedDataCall dataString
> originalDataOriginal data (JSON)JSON String
> callDataTypeOperation type (authorization, subscription, redemption, claim)String

Request example#

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
}'

Response example#

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"
      }
    ]
  }
}