Generate Call Data for Redemption Transactions | DeFi API Guide

·

Understanding how to generate call data for redemption transactions is essential for developers integrating decentralized finance (DeFi) functionalities into Web3 applications. This guide walks you through the API structure, parameters, response details, and practical implementation steps for generating secure and accurate redemption transaction data using the OKX DeFi API.

Whether you're building a wallet-as-a-service platform or enhancing user interaction with staking products, mastering this process ensures seamless integration and reliable transaction execution across multiple blockchain networks.

👉 Unlock powerful Web3 tools to streamline your DeFi development workflow.

API Overview

The Generate Call Data for Redemption Transactions API provides the necessary call data required to execute a redemption transaction within supported DeFi investment products. This includes staking positions on networks such as SUI and SOL.

By submitting specific user and investment details, developers receive structured transaction data that can be signed and broadcasted on the appropriate blockchain.

Endpoint

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

This endpoint returns serialized call data suitable for on-chain execution, along with metadata needed for verification and integration.

Request Parameters

To successfully generate redemption call data, the following parameters must be included in the request body:

Key Use Cases for extra

For staking products such as:

You can retrieve the investOrderList field—including redeemExtra values—using the Calculation & Query Info for Redemption API. This ensures accurate reconstruction of redemption paths based on past user activity.

👉 Access comprehensive Web3 APIs to enhance your DeFi application’s capabilities.

Response Structure

Upon successful request processing, the API returns a structured response containing all necessary transaction components:

Verification & Security

To ensure data integrity and prevent tampering, OKX signs all generated call data. You can optionally verify this signature using the following method:

  1. Extract Signature Components
    Parse signatureData to obtain the elliptic curve signature values: r, s, and recovery parameter v.
  2. Reconstruct Verification Hash
    Concatenate the following strings in order:

    • to
    • serializedData
    • originalData

    Compute the Keccak-256 hash of the concatenated string.

  3. Recover Public Key
    Using ECDSA recovery with the hash and signature (r, s, v), derive the public key. If it matches OKX’s known signing key, the data is authentic.

This verification step is optional but highly recommended for high-security environments where trustless validation is critical.

Redemption Workflow Example

Let’s walk through a real-world scenario: a user wants to redeem their SUI staking position.

Step 1: Fetch Investment Details

Use the query API to get the user’s investment history and extract redeemExtra from investOrderList.

Step 2: Construct Request

{
  "address": "0xabc123...",
  "investmentId": "20801",
  "userInputList": [
    {
      "coinAmount": "500",
      "tokenAddress": "0xdef456..."
    }
  ],
  "expectOutputList": [
    {
      "coinAmount": "750",
      "tokenAddress": "0xghi789..."
    }
  ],
  "extra": "{\"redeemExtra\":\"0x...\"}"
}

Step 3: Receive and Validate Response

OKX returns:

{
  "dataList": [
    {
      "from": "0xabc123...",
      "to": "0xcontract...",
      "value": "",
      "serializedData": "0xa1b2c3...",
      "originalData": "{\"investmentId\":\"20801\",...}",
      "callDataType": "redemption",
      "signatureData": "0x4b5a..."
    }
  ]
}

Step 4: Sign and Broadcast

The client signs the transaction using the user’s private key and broadcasts it via a node or RPC provider.

Frequently Asked Questions (FAQ)

Q: What blockchains are supported for redemption transactions?
A: The API supports multiple chains including Ethereum, BSC, Solana, and SUI. The exact list depends on active DeFi offerings—always check current investment IDs for compatibility.

Q: Is it mandatory to verify the signatureData?
A: No, verification is optional. However, it enhances security by confirming that call data originates from OKX and hasn’t been altered.

Q: Can I redeem partial amounts from a staking position?
A: Yes, most staking products support partial redemptions. Ensure coinAmount reflects the correct proportion and matches backend rules.

Q: What happens if I omit tokenAddress in userInputList?
A: The system defaults to the primary token associated with the investmentId. Only omit if intending to use the default asset.

Q: How do I handle errors during redemption?
A: Check the HTTP status code and error message in the response. Common issues include invalid addresses, insufficient balance, or incorrect chain IDs.

Q: Can this API be used for non-staking DeFi products?
A: Yes, it supports various DeFi instruments including liquidity pool exits and yield vault withdrawals—provided they are listed under supported investment types.

👉 Start building secure, scalable Web3 experiences with trusted infrastructure.

Conclusion

Generating redemption transaction call data via the OKX DeFi API enables developers to offer users a smooth and secure way to exit investments across multiple blockchains. With clear parameter definitions, built-in security signatures, and support for complex staking mechanisms, this API simplifies integration while maintaining high standards of reliability.

By leveraging structured responses and optional verification workflows, your application can ensure both functional accuracy and user trust—key pillars in modern Web3 development.