跳至主要內容

Gas Fee

tokenview大约 2 分钟

Gas Fee

最佳手续费

GET https://services.tokenview.io/vipapi/eth/gas/nextblock?apikey={apikey}

参数

支持公链:eth

Gas Fee 的计算公式

units of gas used * (base fee + priority fee)

  • units of gas used: 交易花费的gas单位数量 ,标准的一次简单ETH转账交易需要21000单位的gas
  • base fee: 基础gas费,单位是gwei (1gwei = 0.000000001 ETH)
  • priority fee: 优先费 或者说是给矿工的小费 和base fee 一样,单位为gwei

据此,要想预估一笔交易的最佳手续费,只需精准的预估转账交易需要的基础gas单位[gasUsed]。例如一次标准ETH转账交易[Transfer]需要21000单位的gas,而创建合约[CREATE]需要32000单位的gas。然后再与该接口返回的数据进行运算即可得到预估的最佳手续费。

Request

curl --location https://services.tokenview.io/vipapi/eth/gas/nextblock?apikey={apikey}

Response

{
    "code": 1,
    "msg": "成功",
    "data": {
        "nextBlockNum": 18210999,
        "midPriorityFee": "0.59",
        "highPriorityFee": "1.98",
        "lowPriorityFee": "0.1",
        "nextBlockNumBaseFee": "7.1"
    }
}

应答字段说明

{
    "code": 1,
    "msg": "成功",
    "data": {
        "nextBlockNum": 18210999, // 下一个块高
        "midPriorityFee": "0.59", // 预估优先费(50%)
        "highPriorityFee": "1.98",// 预估优先费(75%)
        "lowPriorityFee": "0.1",  // 预估优先费(25%)
        "nextBlockNumBaseFee": "7.1" // Base Fee
    }
}

Mempool Gas

GET https://services.tokenview.io/vipapi/pendingstat/{公链简称小写}?apikey={apikey}

参数

Request

curl --location https://services.tokenview.io/vipapi/pendingstat/eth?apikey={apikey}

Response

{
    "code": 1,
    "msg": "成功",
    "data": {
        "bestGasPrice": "19390571044",
        "totalCnt": 185931,
        "minGasPrice": "1",
        "totalSentValue": "4219.529870133152669647",
        "totalFee": "183.903799507071271027",
        "maxGasPrice": "228000000000",
        "totalTokenTransferCnt": 445,
        "totalCallTransferCnt": 0
    }
}

应答字段说明

{
  "code": 1,
  "msg": "成功",
  "data": {
    "bestGasPrice": "273488197", // 最佳gas价格
    "totalCnt": 4245,   // 未确认交易笔数
    "minGasPrice": "100000000",   // 最小gas价格
    "totalSentValue": "403.823851911631256720", // 总交易额
    "totalFee": "8.272538731340059391", // 总手续费
    "totalCallTransferCnt": 0,  // 总合约交易笔数
    "totalTokenTransferCnt": 78 // 总Token交易笔数
  }
}
上次编辑于: