DEX API

查询交易状态#

根据 txhash 查询单链兑换最终交易状态。

请求地址#

GET https://www.okx.com/api/v5/dex/aggregator/history

请求参数#

参数类型必传描述
chainIdString链 ID (如1: Ethereum,更多可查看链 ID 列表)
hashString通过 OKX DEX API 发出的兑换交易 hash
isFromMyProjectBoolean"传 true,判断是否来自当前请求的 API Key 下的订单。不传或传 false,查询任意来自 OKX DEX API 发出的订单"

响应参数#

参数类型描述
chainIdString链的唯一标识。 (如1: Ethereum,更多可查看链 ID 列表)
txHashString交易 Hash
heightString交易发生的区块高度
txTimeString交易时间;Unix时间戳的毫秒数格式
statusStringPENDING (执行中)SUCCESS (成功)FAILURE(失败)
txTypeString交易行为。Approve,Wrap,Unwrap,Swap
fromAddressString发送地址
dexrouterString交互地址
toAddressString接收地址
fromTokenDetailsArray询价详情
>symbolString询价币种简称
>amountString询价币种的兑换数量,按最小数量返回,如 ETH 链,wei。
>tokenAddressString询价币种合约地址 (如0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
toTokenDetailsArray兑换详情
>symbolString目标币种简称
>amountString目标币种的兑换数量,按最小数量返回。
>tokenAddressString目标币种合约地址 (如0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48)
referalAmountString分佣金额
errorMsgString错误信息
gasLimitStringgas限额
gasUsedStringgas消耗。以最小数量返回,例如 ETH 链,wei。
gasPriceStringgas价格。以最小数量返回,例如 ETH 链,wei。
txFeeString手续费,返回主链币消耗数量。

请求示例#

shell
curl --location --request GET 'https://www.okx.com/api/v5/dex/aggregator/history?chainId=784&txHash=5GePcvqEakoUtArW8PHULDSQds95vcgeiTznvbnb8hCV' \
--header 'OK-ACCESS-PROJECT: 86af********d1bc' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z'

响应示例#

200
{
    "code": "0",
    "data": {
        "chainId": "784",
        "dexRouter": "0x51159f25f262ae01e87532b673de3b38df8f0ecc2dc0581f1033df6b84b84955",
        "errorMsg": "",
        "fromAddress": "0x4b9df646075d8621e2578f14818427e4c708709744ea3b827136056f85f88da7",
        "fromTokenDetails": {
            "amount": "892919000000.000",
            "symbol": "HIPPO",
            "tokenAddress": "0x8993129d72e733985f7f1a00396cbd055bad6f817fee36576ce483c8bbb8b87b::sudeng::SUDENG"
        },
        "gasLimit": "",
        "gasPrice": "",
        "gasUsed": "",
        "height": "99502953",
        "referralAmount": "892919000",
        "status": "success",
        "toAddress": "0x4b9df646075d8621e2578f14818427e4c708709744ea3b827136056f85f88da7",
        "toTokenDetails": {
            "amount": "1532443840.00000000",
            "symbol": "SUI",
            "tokenAddress": "0x2::sui::SUI"
        },
        "txFee": "7976416",
        "txHash": "5GePcvqEakoUtArW8PHULDSQds95vcgeiTznvbnb8hCV",
        "txTime": "1736390263909",
        "txType": "swap"
    },
    "msg": ""
}