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
| Parameter | Description | Type | Required | Data Type |
|---|---|---|---|---|
address | User wallet address | Body | Yes | String |
investmentId | Investment product ID | Body | Yes | String |
userInputList | User-input token details | Body | Yes | Array |
chainId | Blockchain ID (default: product network) | Body | No | String |
coinAmount | Subscription amount | Body | Yes | String |
tokenAddress | Token contract address (default: product token) | Body | No | String |
expectOutputList | Expected output details | Body | Yes | Array |
extra | Additional metadata (see notes) | Body | No | String |
Key Notes:
extraField:
Used for specific cases like STX staking investments.
Example:rewardAddress(String) specifies the BTC reward wallet address for the user.
Response Parameters
| Parameter | Description | Data Type |
|---|---|---|
dataList | Call data details | Array |
from | Sender address (user) | String |
to | Recipient address (contract) | String |
value | Native token transfer amount | String |
serializedData | Call data payload | String |
originalData | Raw JSON transaction data | JSON |
callDataType | Action type (authorize/subscribe/redeem/claim) | String |
signatureData | Signature for data verification | String |
Signature Verification:
- Derive
r,s,vfromsignatureData. - Generate a hash using concatenated
to + serializedData + originalData. - 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..."
}
]
}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.