交易 API

获取 Gas Price#

动态获取各个链的预估 gas gasPrice。

请求路径#

GET https://web3.okx.com/api/v5/dex/pre-transaction/gas-price

请求参数#

ParameterTypeRequiredDescription
chainIndexString链唯一标识。(如1代表Ethereum。更多可查看这里。)

响应参数#

EVM & Tron#

ParameterTypeDescription
normalString中档 gasPrice。对于EVM,单位为 wei。对于Tron,单位是 SUN
minString低档 gasPrice。对于EVM,单位为 wei。对于Tron,单位是 SUN
maxString高档 gasPrice。对于EVM,单位为 wei。对于Tron,单位是 SUN
supporteip1559Boolean是否支持 1559
eip1559ProtocolObject1559 协议

eip1559 Protocol#

ParameterTypeDescription
eip1559ProtocolObject1559 协议结构
>baseFeeString基础费用,单位为 wei
>proposePriorityFeeString中档小费,单位为 wei
>safePriorityFeeString低档小费,单位为 wei
>fastPriorityFeeString高档小费,单位为 wei

Solana#

ParameterTypeDescription
priorityFeeString优先费。只适用于 Solana
>proposePriorityFeeString中档优先费,单位是 microlamports
>safePriorityFeeString低档优先费,单位是 microlamports
>fastPriorityFeeBoolean低档优先费,单位是 microlamports

请求示例#

shell
curl --location --request GET 'https://web3.okx.com/api/v5/dex/pre-transaction/gas-price?chainIndex=1' \
--header 'Content-Type: application/json' \
--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": [
        {
            "normal" : "21289500000", //中档gasPrice
            "min" : "15670000000",//低档gasPrice
            "max" : "29149000000", //高档gasPrice            
            "supportEip1559" : true,//是否支持1559
            "erc1599Protocol": {
                "suggestBaseFee" : "15170000000",//建议基础费用
                "baseFee" : "15170000000",//基础费用
                "proposePriorityFee" : "810000000",//中档小费
                "safePriorityFee" : "500000000",//低档小费
                "fastPriorityFee" : "3360000000"//高档小费
            },
            "priorityFee":{}
       }     
    ],
    "msg": ""
}