Get Gas Limit#
Retrieve estimated Gas Limit consumption through pre-execution of transaction information.
Request URL#
POST https://web3.okx.com/api/v5/dex/pre-transaction/gas-limit
Request Parameters#
Parameter | Type | Required | Description |
---|---|---|---|
chainIndex | String | Yes | Unique identifier for the chain. e.g., 1 : Ethereum. See more here. |
fromAddress | String | Yes | From address |
toAddress | String | Yes | To address |
txAmount | String | No | Transaction amount. Default value: 0 . 1. For Native token transactions ( where the fromToken is native token. e.g., Ethereum), the txAmount can be set to the native token quantity, or retrieved from /swap api(e.g., txAmount = swapResponse.tx.value ). 2.For non-native token transactions, set txAmount to 0 . The valle must use base unit of the native token, e.g., wei for ETH |
extJson | Object | No | Additional parameters for calldata and other information |
extJson
Parameter | Type | Required | Description |
---|---|---|---|
inputData | String | No | Calldata |
Response Parameters#
Parameter | Type | Description |
---|---|---|
gasLimit | String | Estimated gas limit |
Request Example#
shell
curl --location --request POST 'https://web3.okx.com/api/v5/dex/pre-transaction/gas-limit' \
--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 '{
"fromAddress": "0x383c8208b4711256753b70729ba0cf0cda55efad",
"toAddress": "0x4ad041bbc6fa102394773c6d8f6d634320773af4",
"txAmount": "31600000000000000",
"chainIndex": "1",
"extJson": {
"inputData":"041bbc6fa102394773c6d8f6d634320773af4"
}
}'
Response Example#
200
{
"code": "0",
"data": [
{
"gasLimit": "652683"
}
],
"msg": ""
}