Gas Limit#
通过交易信息的预执行,获取预估消耗的 Gaslimit 。
请求路径#
POST https://web3.okx.com/api/v5/wallet/pre-transaction/gas-limit
请求参数#
| Parameter | Type | Required | Description | 
|---|---|---|---|
| chainIndex | String | Yes | 链唯一标识 | 
| fromAddr | String | Yes | From 地址 | 
| toAddr | String | Yes | To 地址 | 
| txAmount | String | No | 交易的主链币金额,默认为0。 涉及主网币转账的时候必须要携带此参数, 否则将会影响 gaslimit 的计算,以主网币的最小单位传参,例如 ETH wei 。 | 
| extJson | Object | No | 扩展参数,用于添加 calldata 等信息 | 
extJson
| Parameter | Type | Required | Description | 
|---|---|---|---|
| inputData | String | No | calldata | 
响应参数#
| Parameter | Type | Description | 
|---|---|---|
| gasLimit | String | 预估gas limit数额 | 
请求示例#
shell
curl --location --request POST 'https://web3.okx.com/api/v5/wallet/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 '{
    "fromAddr": "0x383c8208b4711256753b70729ba0cf0cda55efad",
    "toAddr": "0x4ad041bbc6fa102394773c6d8f6d634320773af4",
    "txAmount": "31600000000000000",
    "chainIndex": "1",
    "extJson": {
        "inputData":"041bbc6fa102394773c6d8f6d634320773af4"
    }
}'
响应示例#
200
{
        "code": "0",
        "data": [
            {
              "gasLimit": "652683"
            }
        ],
        "msg": ""
}
