Wallet API

Get Gas Limit#

Retrieve estimated Gas Limit consumption through pre-execution of transaction information. Currently supports only EVM networks.

Request Path#

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

Request Parameters#

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier for the chain
fromAddrStringYesFrom address
toAddrStringYesTo address
txAmountStringNoAmount of main chain coins for the transaction. Default is 0. Required for mainnet transfers to calculate gaslimit properly.
extJsonObjectNoAdditional parameters for calldata and other information

extJson

ParameterTypeRequiredDescription
inputDataStringNoCalldata

Response Parameters#

ParameterTypeDescription
gasLimitStringEstimated gas limit

Request Example#

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"
    }
}'

Response Example#

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