钱包 API
获取 Gas Limit

获取 Gas Limit#

通过交易信息的预执行,获取预估消耗的 Gaslimit 。当前仅支持 EVM 的网络。

请求路径#

GET https://www.okx.com/api/waas/wallet/pre-transaction/gas-limit

请求参数#

ParameterTypeRequiredDescription
chainIndexStringYes链唯一标识
fromAddrStringYesFrom地址
toAddrStringYesTo地址
txAmountStringNo交易的主链币金额,默认为0。
涉及主网币转账的时候必须要携带此参数, 否则将会影响gaslimit的计算。
extJsonObjectNo扩展参数,用于添加calldata等信息

extJson

ParameterTypeRequiredDescription
inputDataStringNocalldata

响应参数#

ParameterTypeDescription
gasLimitString预估gas limit数额

请求示例#

shell
curl --location --request POST 'https://www.okx.com/api/v5/waas/wallet/pre-transaction/gas-limit?chainIndex=1&fromAddr=oxsieeelxd&toAddr=ekljljlnbc&txAmount=1&extJson="xxx"' \
--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' \
--data-raw '{
    "fromAddr": "0x383c8208b4711256753b70729ba0cf0cda55efad",
    "toAddr": "0x4ad041bbc6fa102394773c6d8f6d634320773af4",
    "txAmount": "31600000000000000",
    "chainIndex": "3",
    "extJson": {
        "inputData":"041bbc6fa102394773c6d8f6d634320773af4"
    }
}'

响应示例#

200
{
        "code": "0",
        "data": [
            {
              "gasLimit": "652683",
            }
        ],
        "msg": ""
}