Gas Platform ⛽

Gas Platform is an industry leading product that leverages real-time mempool data to deliver transaction gasPrice distribution and precisely predict gasPrice required to get into the next block.

Overview

Gas Platform provides access to:

  • Gas prices needed to have X% probability to qualify for inclusion in the next block. Need a high probability of being confirmed at the expense of spending extra gas? Use the 99% probability prediction. Don't mind if the tx takes 2-3 blocks if it saves some gas? Use the 70% probability prediction.

  • Estimated gas price distribution for the next block. Want a deeper look at live mempool gas statistics? Get a complete breakdown of gas prices in the mempool grouped by gwei.

You can view an introductory video on Gas Platform here.

Authentication

A valid Blocknative apikey is required in the Authorization Header of every request.

Create an account and apikey here.

Ratelimits

Each endpoint is limited to being called once per second per paid tier apikeys, or once per 5 seconds for free tier apikeys. When you exceed your rate limit, the following headers will be included in the response:

  • Retry-After - The time in seconds after which to retry the request

  • X-RateLimit-Reset - The date after which the rate limit will be reset

Example:

Retry-After: 0.495
X-RateLimit-Reset: Mon May 17 2021 22:27:28 GMT+0000 (Coordinated Universal Time)

get
blockprices

https://api.blocknative.com/gasprices/blockprices
Returns a range of confidence intervals for gas prices needed to qualify a transaction for inclusion in the next block. Order of confidence intervals is subject to change.
Request
Response
Request
Headers
Authorization
required
string
Valid apikey
Query Parameters
confidenceLevels
optional
number
Override default confidence level order (99,95,90,80,70) in response with up to 5 confidence levels from 1 - 99 (see example confidence level request below)
n
optional
integer
Override 'estimatedTransactionCount' (see example response). Used to estimate how many transactions will fit in the next block.
Response
200: OK
Success
{
"system": "ethereum",
"network": "main",
"unit": "gwei",
"maxPrice": Number, // Highest priced transaction in the mempool
"currentBlockNumber": Number, // Block number at time of prediction
"msSinceLastBlock": Number, // Milliseconds since the last block was mined relative to when this data was computed
"blockPrices": [
{
"blockNumber": Number, // Block this prediction is for
"baseFeePerGas": 1, // Base fee per gas for current block in gwei
"estimatedTransactionCount": Number, // Number of items we estimate will be included in next block based on mempool snapshot
"estimatedPrices": [
{
"confidence": Number, // 0-99 likelihood the next block will contain a transaction with a gas price >= to the listed price
"price": Number, // Price in gwei
"maxPriorityFeePerGas": Number, // Max priority fee per gas in gwei
"maxFeePerGas": Number, // Max fee per gas in gwei
},
...,
]
}
],
"notice": "This is an early access endpoint. The response schema may change and we make no accuracy guarantees."
}
401: Unauthorized
Key invalid or not provided
{
"msg": "Authorization header must contain a valid apikey"
}
429: Too Many Requests
Rate limit exceeded. Refer to the headers for when to retry the request.
{ "msg":"Too Many Requests" }

Example request

curl -H "Authorization: your-apikey-here" https://api.blocknative.com/gasprices/blockprices

Example custom confidence level request

curl -H "Authorization: your-apikey-here" https://api.blocknative.com/gasprices/blockprices?confidenceLevels=10&confidenceLevels=30&confidenceLevels=50&confidenceLevels=70&confidenceLevels=90

Example Response Payload

{
"system": "ethereum",
"network": "main",
"unit": "gwei",
"maxPrice": 123,
"currentBlockNumber": 13005095,
"msSinceLastBlock": 3793,
"blockPrices": [
{
"blockNumber": 13005096,
"baseFeePerGas": 94.647990462,
"estimatedTransactionCount": 137,
"estimatedPrices": [
{
"confidence": 99,
"price": 104,
"maxPriorityFeePerGas": 9.86,
"maxFeePerGas": 199.16
},
{
"confidence": 95,
"price": 99,
"maxPriorityFeePerGas": 5.06,
"maxFeePerGas": 194.35
},
{
"confidence": 90,
"price": 98,
"maxPriorityFeePerGas": 4.16,
"maxFeePerGas": 193.45
},
{
"confidence": 80,
"price": 97,
"maxPriorityFeePerGas": 2.97,
"maxFeePerGas": 192.27
},
{
"confidence": 70,
"price": 96,
"maxPriorityFeePerGas": 1.74,
"maxFeePerGas": 191.04
}
]
}
]
}

Type0 and Type2 Transactions

Type0 transactions (Pre EIP-1559) should utilize the Price number under each confidence level. Type2 transactions (EIP-1559) should utilize the values for maxPriorityFeePerGas (also known as the "tip") and maxFeePerGas .

Description of Terms

maxPrice

Highest priced transaction in the mempool

currentBlockNumber

Block number at the time of prediction

msSinceLastBlock

Milliseconds since the last block was mined relative to when data was computed

blockNumber

Block this prediction is for

baseFeePerGas

Base fee per gas for current block in gwei. (Only type2 transactions Post EIP-1559 have this value and it's burned by the network upon transaction success).

estimatedTransactionCount

Number of items we estimate will be included in next block based on mempool snapshot

confidence

0-99 likelihood the next block will contain a transaction with a gas price >= to the listed price

Price

Price in Gwei (used for type0 transactions: Pre EIP-1559)

maxPriorityFeePerGas

Max priority fee per gas in gwei also known as the "tip" (used for type2 transactions: EIP-1559)

maxFeePerGas

Max fee per gas in gwei (used for type2 transactions: EIP-1559). Our current max fee heuristic is Base Fee * 2 + Priority Fee. This is to protect against a ‘rapid’ rise in the base fee while your transaction fee is pending. In most cases, the actual transaction fee will approximate Base Fee + Priority Fee.

get
distribution

https://api.blocknative.com/gasprices/distribution
Get the gas price distribution of the highest n priced pending transactions eligible for inclusion in the next block. If n is not specified, it defaults to number of expected transactions in the next block.
Request
Response
Request
Headers
Authorization
required
string
Valid GR8 Hackathon or paid tier apikey
Query Parameters
n
optional
integer
Number of transactions (ordered by gas price) to use to build the distribution.
Response
200: OK
Success
{
"system": "ethereum",
"network": "main",
"unit": "gwei",
"maxPrice": Number, // Highest priced transaction eligible for inclusion in next block
"currentBlockNumber": Number, // Block number at
"msSinceLastBlock": Number, // Milliseconds since last block at time of capture
"topNDistribution": {
"distribution": [ // List of tuples [(price,count), ...], ordered by price
[
Number, // Price in gwei
Number // Transaction count with this price
],
...,
],
"n": Number // Top N priced pending transactions included in this distribution
}
}
401: Unauthorized
Key invalid or not provided
{
"msg": "Authorization header must contain a valid apikey"
}
429: Too Many Requests
Rate limit exceeded. Refer to the headers for when to retry the request.
{ "msg": "Too Many Requests" }

Pending transactions unlikely to be included in the next block due to poor nonce ordering are not included in distribution data

Example request

curl -H "Authorization: your-apikey-here" https://api.blocknative.com/gasprices/distribution