Generating Subscription Transaction Call Data

Β·

Overview

This API provides call data for subscription transactions, enabling seamless integration with DeFi platforms. It facilitates the creation of transaction data required for subscribing to investment products.


API Endpoint

POST https://web3.okx.com/api/v5/defi/transaction/subscription


Request Parameters

ParameterDescriptionTypeRequiredData Type
addressUser wallet addressBodyYesString
investmentIdInvestment product IDBodyYesString
userInputListUser-input token detailsBodyYesArray
chainIdBlockchain ID (default: product network)BodyNoString
coinAmountSubscription amountBodyYesString
tokenAddressToken contract address (default: product token)BodyNoString
expectOutputListExpected output detailsBodyYesArray
extraAdditional metadata (see notes)BodyNoString

Key Notes:


Response Parameters

ParameterDescriptionData Type
dataListCall data detailsArray
fromSender address (user)String
toRecipient address (contract)String
valueNative token transfer amountString
serializedDataCall data payloadString
originalDataRaw JSON transaction dataJSON
callDataTypeAction type (authorize/subscribe/redeem/claim)String
signatureDataSignature for data verificationString

Signature Verification:

  1. Derive r, s, v from signatureData.
  2. Generate a hash using concatenated to + serializedData + originalData.
  3. Validate with recovered public key.
    (Optional but recommended for ensuring OKX-generated data authenticity.)

Example Usage

Request

{
  "address": "0x123...abc",
  "investmentId": "defi_pool_001",
  "userInputList": [
    {
      "chainId": "1",
      "coinAmount": "100",
      "tokenAddress": "0x456...def"
    }
  ],
  "expectOutputList": [
    {
      "chainId": "1",
      "coinAmount": "105",
      "tokenAddress": "0x456...def"
    }
  ],
  "extra": "rewardAddress=0x789...xyz"
}

Response

{
  "dataList": [
    {
      "from": "0x123...abc",
      "to": "0x987...ijk",
      "value": "",
      "serializedData": "0xabcd...1234",
      "originalData": "{...}",
      "callDataType": "subscribe",
      "signatureData": "0xsignature..."
    }
  ]
}

πŸ‘‰ Explore more DeFi APIs


FAQ

1. What is call data in DeFi transactions?

Call data contains encoded instructions for smart contracts, including method calls and parameters. It’s essential for executing transactions on-chain.

2. Why is signature verification optional?

While it ensures data authenticity, some integrations may prioritize speed over validation. However, we recommend enabling it for security.

3. How do I handle failed transactions?

Check the originalData field for error details and ensure gas fees are sufficient for the network.

4. Can I use this API for non-subscription transactions?

No, this endpoint is specifically designed for subscription workflows. Use other API endpoints for redemption or authorization.

5. What chains are supported?

Currently supports Ethereum-compatible chains (chainId=1). Check documentation for updates on additional networks.

πŸ‘‰ Learn advanced DeFi strategies