Skip to content

Latest commit

 

History

History
3153 lines (2763 loc) · 94.2 KB

README.md

File metadata and controls

3153 lines (2763 loc) · 94.2 KB

Ethereum Gas Price Reporting Index

EVM Gas Reporting Index: Catalogue of Transaction Pricing Services and their implementation differences

This originally started as a simple collection of All Gas Price Prediction and Reporting Services and their various formats (i.e. an index of all the different gas pricing api's).

DOI

Report Version Releases:
GitHub release (latest SemVer)
DOI
DOI

SoK: EVM Gas Pricing Methods, Mechanics and Transaction Pricing Services

27 Apr. 2024, doi:10.5281/zenodo.11077372.

Citation

see CITATION.cff

Bacha, S. (2024) “SoK EVM Gas Pricing Methods, Mechanics and Transaction Pricing Services”. Zenodo. doi: 10.5281/zenodo.11077372.

[v2.0.0] Bacha, Sam. (2024). SoK EVM Gas Pricing APIs: Transaction Pricing Services and their implementation differences (Version 2.0.0) [Computer software]. https://doi.org/10.5281/zenodo.1234
[v1.1.12] S. Bacha, (2021, 2022). EVM Gas Reporting Index: Catalog of Transaction Pricing Services and their implementation differences (Version 1.1.12) [Computer software]. https://doi.org/10.5281/zenodo.1234
author = {Bacha, Sam},
license = {CC-2.5-NC/MIT},
title = {{Gas Reporting Index}},
url = {https://github.com/sambacha/gas-reporting},
version = {2.0.0},
month = {11},
year = {2021-2024}
}
Bacha, S. (2021, 2022, 2024). EVM Gas Reporting Index: Catalog of Transaction Pricing Services and their implementation differences (Version 2.0.0) [Computer software]. ~~https://doi.org/10.5281/zenodo.1234~~

EIP-2930: Optional Access List transactions

source, @fvictorio/gas-costs-after-berlin#EIP-2930-Optional-Access-List-transactions

This EIP adds a new type of transaction that can include an access list in the transaction payload. This means that you can declare beforehand which addresses and slots should be considered as accessed before the transaction’s execution starts. For example, an SLOAD of a non-accessed slot costs 2100, but if that slot was included in the transaction’s access list, then that same opcode will cost 100.

But if the gas costs are lower when an address or storage key is already accessed, does this mean that we can add everything to the transaction’s access list and get a gas reduction? Yay, free gas! Well, not exactly, because you also need to pay gas for each address and each storage key that you add.

Let’s see an example. Say we are sending a transaction to contract A. An access list could look like this:

accessList: [{
  address: "<address of A>",
  storageKeys: [
    "0x0000000000000000000000000000000000000000000000000000000000000000"
  ]
}]

If we send a transaction with this access list, and the first opcode that uses the 0x0 slot is a SLOAD, it will cost 100 instead of 2100. That’s a gas reduction of 2000. But each storage key included in the transaction’s access list has a cost of 1900. So we only save 100 of gas. (If the first opcode to access that slot is an SSTORE instead, we would save 2100 of gas, which means that we’d save 200 of gas in total if we consider the cost of the storage key.)

You always pay gas for the address in the access list ("

" in the example).

Accessed addresses

So far, we’ve been talking only about the SLOAD and SSTORE opcodes, but those aren’t the only ones that change after Berlin. For example, the CALL opcode had a fixed cost of 700. But after EIP-2929 its cost is 2600 if the address is not in the access list and 100 if it is. And, like the accessed storage keys, it doesn’t matter what OPCODE accessed that address before (for example, if an EXTCODESIZE was called first, then that opcode will cost 2600, and any subsequent EXTCODESIZE, CALL, STATICCALL that uses the same address will cost 100).

How is this affected by transactions with access lists? For example, if we send a transaction to contract A, and that contract calls another contract B, then we can include an access list like this:

accessList: [{ address: "<address of B>", storageKeys: [] }]

We’ll have to pay a cost of 2400 to include this access list in the transaction, but then the first opcode that uses the address of B will cost 100 instead of 2600. So we saved 100 of gas by doing this. And if B uses its storage somehow and we know which keys it will use, then we can also include them in the access list and save 100/200 of gas for each one (depending on whether the first opcode is an SLOAD or an SSTORE).

But why are we talking about another contract? What happens with the contract that we are calling? Why don’t we do this?

accessList: [
  {address: "<address of A>", storageKeys: []},
  {address: "<address of B>", storageKeys: []},
]

We could do it, but it wouldn’t be worth it because EIP-2929 specifies that the address of the contract that is being called (that is, tx.to) is always included in the accessed_addresses list. So we are paying 2400 more for nothing.

Let’s analyze our example of the previous section again:

accessList: [{
  address: "<address of A>",
  storageKeys: [
    "0x0000000000000000000000000000000000000000000000000000000000000000"
  ]
}]

This will actually be wasteful unless we include several storage keys more. If we assume that a storage key is always used first by an SLOAD, then we need at least 24 storage keys just to break even.

As you can imagine, analyzing this and creating an access list by hand is not fun. Luckily, there is a better way.

eth_createAccessList

Geth (starting from version 1.10.2) includes a new eth_createAccessList RPC method that you can use to generate access lists. It is used like eth_estimateGas, but instead of a gas estimation, it returns something like this:

{
  "accessList": [
    {
      "address": "0xb0ee076d7779a6ce152283f009f4c32b5f88756c",
      "storageKeys": [
        "0x0000000000000000000000000000000000000000000000000000000000000000",
        "0x0000000000000000000000000000000000000000000000000000000000000001"
      ]
    }
  ],
  "gasUsed": "0x8496"
}

That is, it gives you the list of addresses and storage keys that will be used by that transaction, plus the gas consumed if the access list is included. (And, like eth_estimateGas, this is an estimation; the list could change when the transaction is actually mined.) But, again, this doesn’t mean that this gas will be lower than the gas used if you just send the same transaction without an access list!

Conclusion

Does this mean that we always save gas when using transaction’s with access lists? No.

MetaMask Gas Fee API

https://gas.api.infura.io/networks/1/suggestedGasFees

NOTE GET https://gas.api.infura.io/networks/${chainId}/suggestedGasFees

  • low, medium, high - Object containing recommended values for transactions by level of urgency:
    • suggestedMaxPriorityFeePerGas: string - The maximum suggested priority fee per gas (in gwei) to pay to have transactions included in a block.
    • suggestedMaxFeePerGas: string - The maximum suggested total fee per gas (in gwei) to pay, including both the base fee and the priority fee.
    • minWaitTimeEstimate: number - The minimum estimated wait time (in milliseconds) for a transaction to be included in a block at the suggested gas price.
    • maxWaitTimeEstimate: number - The maximum estimated wait time (in milliseconds) for a transaction to be included in a block at the suggested gas price.
  • estimatedBaseFee: string - The current estimated base fee per gas on the network.
  • networkCongestion: number - The current congestion on the network, represented as a number between 0 and 1. A lower network congestion score (for example 0.1), indicates that fewer transactions are being submitted, so it's cheaper to validate transactions.
  • latestPriorityFeeRange: array - The range of priority fees per gas for recent transactions on the network.
  • historicalPriorityFeeRange: array - The range of priority fees per gas for transactions on the network over a historical period.
  • historicalBaseFeeRange: array - The range of base fees per gas on the network over a historical period.
  • priorityFeeTrend: string - The current trend in priority fees on the network, either up or down (whether it's getting more expensive or cheaper).
  • baseFeeTrend: string - The current trend in base fees on the network, either up or down (whether it's getting more expensive or cheaper).

source https://docs.metamask.io/services/reference/gas-api/api-reference/gasprices-type2/

Example Return

Priority Level Suggested Max Priority Fee Per Gas Suggested Max Fee Per Gas Min Wait Time Estimate (ms) Max Wait Time Estimate (ms)
Low N/A N/A 15000 60000
Medium 0.97 11.694730357 15000 45000
High 2 19.249566308 15000 30000
Additional Data Value
Estimated Base Fee 7.499811438
Network Congestion 0.0305
{
  "low": {
    "suggestedMaxPriorityFeePerGas": "0.008836",
    "suggestedMaxFeePerGas": "7.508647438",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 60000
  },
  "medium": {
    "suggestedMaxPriorityFeePerGas": "0.97",
    "suggestedMaxFeePerGas": "11.694730357",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 45000
  },
  "high": {
    "suggestedMaxPriorityFeePerGas": "2",
    "suggestedMaxFeePerGas": "19.249566308",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 30000
  },
  "estimatedBaseFee": "7.499811438",
  "networkCongestion": 0.0305,
  "latestPriorityFeeRange": [
    "0.0094",
    "5.249868006"
  ],
  "historicalPriorityFeeRange": [
    "0.000824616",
    "269.34304631"
  ],
  "historicalBaseFeeRange": [
    "7.061724017",
    "10.741515604"
  ],
  "priorityFeeTrend": "up",
  "baseFeeTrend": "up",
  "version": "0.0.1"
}

Gas Fee Speed Definitions

  • Fastest: next block (i.e. <30 seconds)
  • Fast: below 2 minutes (<10 blocks)
  • Medium: around 5 minutes (<20 blocks)
  • Slow: below 30 minutes (a.k.a safe-low, <120 blocks)

Gas Reporting Table Format

Gas Reporting from forge test --gas-report

forge snapshot

CONTRACT_NAME:string
Deployment Cost Deployment Size
type:number type:number
Function Name min avg median max # calls
type:string type:number type:number type:number type:number type:number

Gas Snapshot Format

.gas-snapshot

FooTest:testSetFoo() (gas: 64071)
BarTest:testFuzzCurrentBar(uint256) (runs: 256, μ: 408, ~: 423)

runs: {runs}, μ: {mean_gas}, ~: {median_gas})

JSON-Schema definition

Each test object represents a test function and has the following properties:

key boolean value
name (required) The name of the test function.
gas (optional) The gas used by the test function. This property is required if the test is not a fuzz test.
runs (optional) The number of runs for the test function. This property is required if the test is a fuzz test.
avg (optional) The average gas used across all runs. This property is required if the test is a fuzz test.
median (optional) The median gas used across all runs. This property is required if the test is a fuzz test.

The oneOf constraint ensures that a test object must have either the gas property (for non-fuzz tests) or the runs, avg, and median properties (for fuzz tests).

This JSON Schema describes the structure of the .gas-snapshot file format used by Forge. It allows for both regular tests with a single gas value and fuzz tests with multiple runs and statistical data (average and median gas used).

gas-snapshot

The schema defines an object with a single property tests, which is an array of test objects.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "tests": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the test function"
          },
          "gas": {
            "type": "integer",
            "description": "The gas used by the test function"
          },
          "runs": {
            "type": "integer",
            "description": "The number of runs for the test function (only applicable for fuzz tests)"
          },
          "avg": {
            "type": "integer",
            "description": "The average gas used across all runs (only applicable for fuzz tests)"
          },
          "median": {
            "type": "integer",
            "description": "The median gas used across all runs (only applicable for fuzz tests)"
          }
        },
        "required": [
          "name"
        ],
        "oneOf": [
          {
            "required": [
              "gas"
            ]
          },
          {
            "required": [
              "runs",
              "avg",
              "median"
            ]
          }
        ]
      }
    }
  },
  "required": [
    "tests"
  ]
}

Example output

╭──────────────────────────┬─────────────────┬───────┬────────┬───────┬─────────╮
│ GasMeterFactory contract ┆                 ┆       ┆        ┆       ┆         │
╞══════════════════════════╪═════════════════╪═══════╪════════╪═══════╪═════════╡
│ Deployment Cost          ┆ Deployment Size ┆       ┆        ┆       ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ 35287                    ┆ 206             ┆       ┆        ┆       ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ Function Name            ┆ min             ┆ avg   ┆ median ┆ max   ┆ # calls │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ build                    ┆ 38653           ┆ 38653 ┆ 38653  ┆ 38653 ┆ 15      │
╰──────────────────────────┴─────────────────┴───────┴────────┴───────┴─────────╯

eth_maxPriorityFeePerGas

Definition

https://github.com/ethereum/execution-apis/blob/main/src/eth/fee_market.yaml

The eth_maxPriorityFeePerGas was originally a client specific RPC Method (go-ethereum), it only recently was made part of the official Ethereum JSON-RPC specification. This method was introduced as part of the EIP-1559 (Ethereum Improvement Proposal 1559) transaction pricing mechanism implementation by the go-ethereum team. It is used to retrieve the current maximum priority fee per gas accepted for the network.

You can calculate a default maxPriorityFeePerGas using eth_feeHistory when eth_maxPriorityFeePerGas is not available.

Calculating the current maximum priority fee per gas

The eth_maxPriorityFeePerGas method allows users, wallets, and dApps to query the Ethereum node and obtain the current maximum priority fee per gas.

The priority fee is an additional fee that can be added to a transaction to incentivize miners to prioritize its inclusion in a block. The returned value represents the maximum priority fee per gas in wei, and this value is a dynamic parameter and can change over time depending on network congestion and block builder preferences.

It represents the maximum accepted priority fee at a given moment but does not guarantee that a transaction with that priority fee will be included in the next block. Inclusion depends on various factors such as gas price, gas limit, and transaction competition.

Go-Ethereum Calculation

Client implementations can vary, for example in go-ethereum (geth) it calculates what is the 60th percentile tip over the last 20 blocks by default.

https://github.com/ethereum/go-ethereum/blob/f265cc24b4b17b55b468b315303a3a599fc01d81/eth/ethconfig/config.go#L40-L47

// FullNodeGPO contains default gasprice oracle settings for full node.
var FullNodeGPO = gasprice.Config{
	Blocks:           20,
	Percentile:       60,
	MaxHeaderHistory: 1024,
	MaxBlockHistory:  1024,
	MaxPrice:         gasprice.DefaultMaxPrice,
	Igno

Usage:

To use this method, you need to send a JSON-RPC request to an Ethereum node with the method name eth_maxPriorityFeePerGas.

The request does not require any parameters.

eth_feeHistory

Definition

https://github.com/ethereum/execution-apis/blob/main/src/eth/fee_market.yaml

eth_feeHistory returns transaction base fee per gas and effective priority fee per gas for the requested/supported block range.

The request does require the following parameters:

blockCount: Requested range of blocks. Clients will return less than the requested range if not all blocks are available.
rewardPercentiles: A monotonically increasing list of percentile values. For each block in the requested range, the transactions will be sorted in ascending order by effective tip per gas and the corresponding effective tip for the percentile will be determined, accounting for gas consumed.
gasUsedRatio: An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit.

Gas Pricing API Providers and Oracles

Listed in no particular order.

Notice: GasNow as of 2021-10-01 will be shutting down due to SparkPools closure

Blocknative

@note there are two seperate entries

gas.blocknative.com

Note: This is powered by Blocknative's global mempool data platform

v2 Blocknative

{
    "system": "ethereum",
    "network": "main",
    "unit": "gwei",
    "maxPrice": 50,
    "currentBlockNumber": 15326495,
    "msSinceLastBlock": 40251,
    "blockPrices": [
        {
            "blockNumber": 15326496,
            "estimatedTransactionCount": 322,
            "baseFeePerGas": 11.075381056,
            "estimatedPrices": [
                {
                    "confidence": 99,
                    "price": 13,
                    "maxPriorityFeePerGas": 2.49,
                    "maxFeePerGas": 22.45
                },
                {
                    "confidence": 95,
                    "price": 13,
                    "maxPriorityFeePerGas": 2.13,
                    "maxFeePerGas": 22.09
                },
                {
                    "confidence": 90,
                    "price": 12,
                    "maxPriorityFeePerGas": 1.92,
                    "maxFeePerGas": 21.88
                },
                {
                    "confidence": 80,
                    "price": 12,
                    "maxPriorityFeePerGas": 1.68,
                    "maxFeePerGas": 21.64
                },
                {
                    "confidence": 70,
                    "price": 12,
                    "maxPriorityFeePerGas": 1.58,
                    "maxFeePerGas": 21.54
                }
            ]
        }
    ],
    "estimatedBaseFees": [
        {
            "pending+1": [
                {
                    "confidence": 99,
                    "baseFee": 12.46
                }
            ]
        },
        {
            "pending+2": [
                {
                    "confidence": 99,
                    "baseFee": 14.02
                }
            ]
        },
        {
            "pending+3": [
                {
                    "confidence": 99,
                    "baseFee": 15.77
                }
            ]
        },
        {
            "pending+4": [
                {
                    "confidence": 99,
                    "baseFee": 17.75
                }
            ]
        },
        {
            "pending+5": [
                {
                    "confidence": 99,
                    "baseFee": 19.96
                }
            ]
        }
    ]
}

v1 Blocknative

{
  "system": "ethereum",
  "network": "main",
  "unit": "gwei",
  "maxPrice": 336,
  "currentBlockNumber": 13095949,
  "msSinceLastBlock": 4542,
  "blockPrices": [
    {
      "blockNumber": 13095950,
      "baseFeePerGas": 113.110076547,
      "estimatedTransactionCount": 172,
      "estimatedPrices": [
        {
          "confidence": 99,
          "price": 129,
          "maxPriorityFeePerGas": 15.96,
          "maxFeePerGas": 242.18
        },
        {
          "confidence": 95,
          "price": 119,
          "maxPriorityFeePerGas": 6.84,
          "maxFeePerGas": 233.06
        },
        {
          "confidence": 90,
          "price": 118,
          "maxPriorityFeePerGas": 5.09,
          "maxFeePerGas": 231.31
        },
        {
          "confidence": 80,
          "price": 116,
          "maxPriorityFeePerGas": 3.21,
          "maxFeePerGas": 229.43
        },
        {
          "confidence": 70,
          "price": 115,
          "maxPriorityFeePerGas": 2.28,
          "maxFeePerGas": 228.5
        }
      ]
    }
  ]
}

bnc-ext

BlockNative Chrome Extenstion

blocknative eth gas estimate extenstion

https://blocknative-api.herokuapp.com/data

sample response

{
  "pendingBlockNumberVal": 13378149,
  "seconds": 17,
  "maxPrice": 768,
  "estimatedTransactions": 279,
  "estimatedPrices": [{
    "confidence": 99,
    "price": 86,
    "maxPriorityFeePerGas": 2.96,
    "maxFeePerGas": 170.76
  }, {
    "confidence": 95,
    "price": 85,
    "maxPriorityFeePerGas": 1.75,
    "maxFeePerGas": 169.55
  }, {
    "confidence": 90,
    "price": 85,
    "maxPriorityFeePerGas": 1.56,
    "maxFeePerGas": 169.36
  }, {
    "confidence": 80,
    "price": 85,
    "maxPriorityFeePerGas": 1.48,
    "maxFeePerGas": 169.28
  }, {
    "confidence": 70,
    "price": 85,
    "maxPriorityFeePerGas": 1.37,
    "maxFeePerGas": 169.17
  }],
  "baseFeePerGas": 83.897778652
}

Curve-Finance

getGas

https://api.curve.fi/api/getGas

 https://api.curve.fi/api/getGas
{
    "success": true,
    "data": {
        "gas": {
            "rapid": 36000000000,
            "fast": 35000000000,
            "standard": 35000000000,
            "slow": 35000000000
        },
        "eip1559Gas": {
            "base": 35292604977,
            "prio": [
                1220000000,
                500000000,
                350000000,
                230000000
            ],
            "max": [
                56110000000,
                55390000000,
                55240000000,
                55120000000
            ]
        }
    },
    "generatedTimeMs": 1668181797396
}

WalletConnect

specification

https://github.com/pedrouid/ethereum-api#api

https://ethereum-api.xyz/gas-prices

http GET https://ethereum-api.xyz/gas-prices

sample response

{
  "timestamp": 1633172858972,
  "slow": {
    "time": 756,
    "price": 39
  },
  "average": {
    "time": 84,
    "price": 42
  },
  "fast": {
    "time": 30,
    "price": 54
  },
  "fastest": {
    "time": 24,
    "price": 58
  }
}

Flashbots

eth_gasFee

specification

see source documentation

// prettier-ignore

{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    block,                     // Number, current block number
    baseFeePerGas,             // String, a hex number for the baseFee at the current block
    default: {
      maxFeePerGas,            // String, a hex number for the recommended default maxFeePerGas
      maxPriorityFeePerGas,    // String, a hex number for the recommended default maxPriorityFeePerGas
    },
    low: {
      maxFeePerGas,            // String, a hex number for the recommended low maxFeePerGas
      maxPriorityFeePerGas,    // String, a hex number for the recommended low maxPriorityFeePerGas
    },
    med: {
      maxFeePerGas,            // String, a hex number for the recommended med maxFeePerGas
      maxPriorityFeePerGas,    // String, a hex number for the recommended med maxPriorityFeePerGas
    },
    high: {
      maxFeePerGas,            // String, a hex number for the recommended high maxFeePerGas
      maxPriorityFeePerGas,    // String, a hex number for the recommended high maxPriorityFeePerGas
    },
  }
}

request sample

curl -s -L -X POST 'https://protection.flashbots.net/v1/rpc' \
-H 'Content-Type: application/json' \
--data-raw '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_gasFees",
  "params": []
}'

response

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "block": 13467179,
        "baseFeePerGas": "0x0bd0606957",
        "default": {
            "maxFeePerGas": "0x12ec776ebc",
            "maxPriorityFeePerGas": "0x01e47257df"
        },
        "low": {
            "maxFeePerGas": "0x11d7682749",
            "maxPriorityFeePerGas": "0xe45ecec3"
        },
        "med": {
            "maxFeePerGas": "0x12ec776ebc",
            "maxPriorityFeePerGas": "0x01e47257df"
        },
        "high": {
            "maxFeePerGas": "0x1412552c31",
            "maxPriorityFeePerGas": "0x0302bff9d4"
        }
    }
}

EtherScan

https://docs.etherscan.io/api-endpoints/gas-tracker

https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=YourApiKeyToken

{
  "status": "1",
  "message": "OK",
  "result": {
    "LastBlock": "13053741",
    "SafeGasPrice": "20",
    "ProposeGasPrice": "22",
    "FastGasPrice": "24",
    "suggestBaseFee": "19.230609716",
    "gasUsedRatio": "0.370119078777807,0.8954731,0.550911766666667,0.212457033333333,0.552463633333333"
  }
}

GasNow [no longer in service]

gasnow.org/taichi

wss://www.gasnow.org/ws
{
  "type": "gasprice",
  "data": {
    "gasPrices": {
      "rapid": 67000000000,
      "fast": 64455346560,
      "standard": 63455346560,
      "slow": 63455346560
    },
    "cumulativeCounts": [
      {
        "gwei": "63",
        "cumulativeCount": 93
      },
      {
        "gwei": "64",
        "cumulativeCount": 81
      },
      {
        "gwei": "65",
        "cumulativeCount": 65
      },
      {
        "gwei": "66",
        "cumulativeCount": 35
      },
      {
        "gwei": "67",
        "cumulativeCount": 34
      },
      {
        "gwei": "68",
        "cumulativeCount": 32
      },
      {
        "gwei": "69",
        "cumulativeCount": 30
      },
      {
        "gwei": "70",
        "cumulativeCount": 25
      },
      {
        "gwei": "71",
        "cumulativeCount": 22
      },
      {
        "gwei": "73",
        "cumulativeCount": 21
      },
      {
        "gwei": "74",
        "cumulativeCount": 19
      },
      {
        "gwei": "75",
        "cumulativeCount": 17
      },
      {
        "gwei": "78",
        "cumulativeCount": 16
      },
      {
        "gwei": "80",
        "cumulativeCount": 15
      },
      {
        "gwei": "81",
        "cumulativeCount": 13
      },
      {
        "gwei": "87",
        "cumulativeCount": 12
      },
      {
        "gwei": "88",
        "cumulativeCount": 11
      },
      {
        "gwei": "89",
        "cumulativeCount": 9
      },
      {
        "gwei": "94",
        "cumulativeCount": 8
      },
      {
        "gwei": "96",
        "cumulativeCount": 6
      },
      {
        "gwei": "98",
        "cumulativeCount": 5
      },
      {
        "gwei": "109",
        "cumulativeCount": 4
      },
      {
        "gwei": "112",
        "cumulativeCount": 3
      },
      {
        "gwei": "120",
        "cumulativeCount": 2
      },
      {
        "gwei": "221",
        "cumulativeCount": 1
      }
    ],
    "timestamp": 1629975608579
  }
}

GasNow Legacy

{
  "code": 200,
  "data": {
    "rapid": 131000000000,
    "fast": 116000000000,
    "standard": 100000000000,
    "slow": 91600000000,
    "timestamp": 1613914581546
  }
}

Gnosis

endpoint url

{
  "lastUpdate": "2021-02-21T13:38:38.945308Z",
  "lowest": "2",
  "safeLow": "109000000001",
  "standard": "119000000001",
  "fast": "131000000001",
  "fastest": "10680081443136"
}

MetaMask

Consensys CoDeFi

endpoint url

{
  "low": {
    "suggestedMaxPriorityFeePerGas": "1.37826449268",
    "suggestedMaxFeePerGas": "70.067746222",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 30000
  },
  "medium": {
    "suggestedMaxPriorityFeePerGas": "1.5",
    "suggestedMaxFeePerGas": "81.637728684",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 45000
  },
  "high": {
    "suggestedMaxPriorityFeePerGas": "2",
    "suggestedMaxFeePerGas": "93.585975639",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 60000
  },
  "estimatedBaseFee": "57.241234774",
   "networkCongestion": 0.5,
}
{
  "SafeGasPrice": "100",
  "ProposeGasPrice": "108",
  "FastGasPrice": "119"
}

1inch

https://gas-price-api.1inch.exchange/v1.0

v1.0

{
  "fast": 96820000000,
  "instant": 125000000000,
  "standard": 90000000000,
  "slow": 82000000000
}

v1.2

gas-price-api.1inch.io/v.1.2

{
    "baseFee": "93731028208",
    "low": {
        "maxPriorityFeePerGas": "1170000000",
        "maxFeePerGas": "94901028208"
    },
    "medium": {
        "maxPriorityFeePerGas": "2340000000",
        "maxFeePerGas": "96071028208"
    },
    "high": {
        "maxPriorityFeePerGas": "5850000000",
        "maxFeePerGas": "99581028208"
    },
    "instant": {
        "maxPriorityFeePerGas": "5850000000",
        "maxFeePerGas": "129455336670"
    }
}

ethGasStation

endpoint url

{
  "fast": 1200.0,
  "fastest": 1200.0,
  "safeLow": 1020.0,
  "average": 1050.0,
  "block_time": 13.327868852459016,
  "blockNum": 11900622,
  "speed": 0.997822721438169,
  "safeLowWait": 12.9,
  "avgWait": 1.5,
  "fastWait": 0.5,
  "fastestWait": 0.5,
  "gasPriceRange": {
    "1200": 0.5,
    "1180": 0.5,
    "1160": 0.6,
    "1140": 0.6,
    "1120": 0.7,
    "1100": 0.7,
    "1080": 1.2,
    "1060": 1.5,
    "1040": 11.5,
    "1020": 12.9,
    "1000": 14.3,
    "980": 17.4,
    "960": 18.9,
    "940": 21.1,
    "920": 222.1,
    "900": 222.1,
    "880": 222.1,
    "860": 222.1,
    "840": 222.1,
    "820": 222.1,
    "800": 222.1,
    "780": 222.1,
    "760": 222.1,
    "740": 222.1,
    "720": 222.1,
    "700": 222.1,
    "680": 222.1,
    "660": 222.1,
    "640": 222.1,
    "620": 222.1,
    "600": 222.1,
    "580": 222.1,
    "560": 222.1,
    "540": 222.1,
    "520": 222.1,
    "500": 222.1,
    "480": 222.1,
    "460": 222.1,
    "440": 222.1,
    "420": 222.1,
    "400": 222.1,
    "380": 222.1,
    "360": 222.1,
    "340": 222.1,
    "320": 222.1,
    "300": 222.1,
    "280": 222.1,
    "260": 222.1,
    "240": 222.1,
    "220": 222.1,
    "200": 222.1,
    "190": 222.1,
    "180": 222.1,
    "170": 222.1,
    "160": 222.1,
    "150": 222.1,
    "140": 222.1,
    "130": 222.1,
    "120": 222.1,
    "110": 222.1,
    "100": 222.1,
    "90": 222.1,
    "80": 222.1,
    "70": 222.1,
    "60": 222.1,
    "50": 222.1,
    "40": 222.1,
    "30": 222.1,
    "20": 222.1,
    "10": 222.1,
    "8": 222.1,
    "6": 222.1,
    "4": 222.1,
    "1050": 1.5
  }
}
{
  "fast": 1200.0,
  "fastest": 1200.0,
  "safeLow": 1020.0,
  "average": 1050.0,
  "block_time": 13.327868852459016,
  "blockNum": 11900622,
  "speed": 0.997822721438169,
  "safeLowWait": 12.9,
  "avgWait": 1.5,
  "fastWait": 0.5,
  "fastestWait": 0.5,
  "gasPriceRange": {
    "1200": 0.5,
    "1180": 0.5,
    "1160": 0.6,
    "1140": 0.6,
    "1120": 0.7,
    "1100": 0.7,
    "1080": 1.2,
    "1060": 1.5,
    "1040": 11.5,
    "1020": 12.9,
    "1000": 14.3,
    "980": 17.4,
    "960": 18.9,
    "940": 21.1,
    "920": 222.1,
    "900": 222.1,
    "880": 222.1,
    "860": 222.1,
    "840": 222.1,
    "820": 222.1,
    "800": 222.1,
    "780": 222.1,
    "760": 222.1,
    "740": 222.1,
    "720": 222.1,
    "700": 222.1,
    "680": 222.1,
    "660": 222.1,
    "640": 222.1,
    "620": 222.1,
    "600": 222.1,
    "580": 222.1,
    "560": 222.1,
    "540": 222.1,
    "520": 222.1,
    "500": 222.1,
    "480": 222.1,
    "460": 222.1,
    "440": 222.1,
    "420": 222.1,
    "400": 222.1,
    "380": 222.1,
    "360": 222.1,
    "340": 222.1,
    "320": 222.1,
    "300": 222.1,
    "280": 222.1,
    "260": 222.1,
    "240": 222.1,
    "220": 222.1,
    "200": 222.1,
    "190": 222.1,
    "180": 222.1,
    "170": 222.1,
    "160": 222.1,
    "150": 222.1,
    "140": 222.1,
    "130": 222.1,
    "120": 222.1,
    "110": 222.1,
    "100": 222.1,
    "90": 222.1,
    "80": 222.1,
    "70": 222.1,
    "60": 222.1,
    "50": 222.1,
    "40": 222.1,
    "30": 222.1,
    "20": 222.1,
    "10": 222.1,
    "8": 222.1,
    "6": 222.1,
    "4": 222.1,
    "1050": 1.5
  }
}

etherchain.org

endpoint url

{"safeLow":1,"standard":1,"fast":1.5,"fastest":2,"currentBaseFee":72.5,"recommendedBaseFee":147.2}
{ "safeLow": 102, "standard": 105, "fast": 114.6, "fastest": 120 }

etherchain-gasnow

https://etherchain.org/api/gasnow

{code: 200, data: {rapid: 60000000000, fast: 39962373278, standard: 24406984375, slow: 19550000000,}}
code: 200
data: {rapid: 60000000000, fast: 39962373278, standard: 24406984375, slow: 19550000000,}
fast: 39962373278
priceUSD: 1818.52
rapid: 60000000000
slow: 19550000000
standard: 24406984375
timestamp: 1654245505826

Response

{"code":200,"data":{"rapid":65265049007,"fast":49988581398,"standard":23000000000,"slow":19550000000,"timestamp":1654245243247,"priceUSD":1818.52}}

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$id": "etherchain_gasnow",
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "data": {
      "type": "object",
      "properties": {
        "rapid": {
          "type": "integer"
        },
        "fast": {
          "type": "integer"
        },
        "standard": {
          "type": "integer"
        },
        "slow": {
          "type": "integer"
        },
        "timestamp": {
          "type": "integer"
        },
        "priceUSD": {
          "type": "number"
        }
      },
      "required": [
        "rapid",
        "fast",
        "standard",
        "slow",
        "timestamp",
        "priceUSD"
      ]
    }
  },
  "required": [
    "code",
    "data"
  ]
}

poanetwork

endpoint url

{
  "health": true,
  "block_number": 11900628,
  "slow": 101.0,
  "standard": 107.0,
  "fast": 115.0,
  "instant": 130.8,
  "block_time": 13.191
}
{
  "health": true,
  "block_number": 11900628,
  "slow": 101.0,
  "standard": 107.0,
  "fast": 115.0,
  "instant": 130.8,
  "block_time": 13.191
}

Zoltu

nanoeth is the SI nomenclature for gwei

{
  "number_of_blocks": 200,
  "latest_block_number": 11907178,
  "percentile_1": "1e-9 nanoeth",
  "percentile_2": "0.00001 nanoeth",
  "percentile_3": "0.000011001 nanoeth",
  "percentile_4": "1 nanoeth",
  "percentile_5": "6 nanoeth",
  "percentile_10": "10 nanoeth",
  "percentile_15": "152 nanoeth",
  "percentile_20": "170 nanoeth",
  "percentile_25": "181.5 nanoeth",
  "percentile_30": "190.000001459 nanoeth",
  "percentile_35": "200 nanoeth",
  "percentile_40": "214.76 nanoeth",
  "percentile_45": "222.814063547 nanoeth",
  "percentile_50": "229.9 nanoeth",
  "percentile_55": "232 nanoeth",
  "percentile_60": "245 nanoeth",
  "percentile_65": "256 nanoeth",
  "percentile_70": "262 nanoeth",
  "percentile_75": "270.6 nanoeth",
  "percentile_80": "278 nanoeth",
  "percentile_85": "289.02 nanoeth",
  "percentile_90": "300 nanoeth",
  "percentile_95": "314.4 nanoeth",
  "percentile_96": "315.21 nanoeth",
  "percentile_97": "316.075841562 nanoeth",
  "percentile_98": "325 nanoeth",
  "percentile_99": "326 nanoeth",
  "percentile_100": "348 nanoeth"
}

MyCrypto

{
  "safeLow": 159,
  "standard": 184,
  "fast": 262,
  "fastest": 289,
  "blockNum": 11907235
}
{
  "safeLow": 159,
  "standard": 184,
  "fast": 262,
  "fastest": 289,
  "blockNum": 11907235
}

EtherScan

api endpoint key required

{
  "status": "1",
  "message": "OK",
  "result": {
    "LastBlock": "11907242",
    "SafeGasPrice": "248",
    "ProposeGasPrice": "269",
    "FastGasPrice": "294"
  }
}
{
  "status": "1",
  "message": "OK",
  "result": {
    "LastBlock": "11907242",
    "SafeGasPrice": "248",
    "ProposeGasPrice": "269",
    "FastGasPrice": "294"
  }
}

Zapper

http://api.zapper.fi/v1/gas-price

{
  "standard": 113,
  "fast": 114,
  "instant": 136
}

archerdao

https://api.archerdao.io/v1/gas

{
  "code": 200,
  "data": {
    "immediate": "228202648099",
    "rapid": "67236905683",
    "fast": "13591066085",
    "standard": "1101380018",
    "slow": "0",
    "slower": "0",
    "slowest": "0"
  }
}

gas-ticker

Gas Ticker by ricmoo

{
  "blockNumber": 14610954,
  "timestamp": 1650309194.438,
  "slow": {
    "min": 29.397486945,
    "max": 70.143180307,
    "sum": 13465.490242759988,
    "count": 385,
    "mean": 34.97529933184413,
    "median": 35,
    "tp90": 38,
    "stdDev": 5.992331436594249,
    "target90": 37.265690661,
    "targetStdDev": 2.7612260317587007,
    "targetCount": 266,
    "targetBest": 30,
    "targetWorst": 39.532494062
  },
  "medium": {
    "min": 29.397486945,
    "max": 62.428616398,
    "sum": 29594.27666106807,
    "count": 680,
    "mean": 43.520995089805986,
    "median": 39.038827568,
    "tp90": 52.433561707,
    "stdDev": 8.816041449214934,
    "target90": 50,
    "targetStdDev": 4.467921632212077,
    "targetCount": 470,
    "targetBest": 34.911631032,
    "targetWorst": 52.3082
  },
  "fast": {
    "min": 29.397486945,
    "max": 1200.988196226,
    "sum": 753432.9418861985,
    "count": 14637,
    "mean": 51.47454682559257,
    "median": 48.554602972,
    "tp90": 59.570121624,
    "stdDev": 24.12932660961557,
    "target90": 60.216413805,
    "targetStdDev": 6.10997036680254,
    "targetCount": 10100,
    "targetBest": 38.822145579,
    "targetWorst": 64.139501286
  }
}

Appendix

Custom Network Over pricing

Metamask will pad the estimated gas without exceeding the most recent block gasLimit. However, If the network is a a custom network it will return the eth_estimateGas value

see metamask/controllers

URL Index

Current offchain list:

EVM Params

Key Value Description
JumpdestGas uint64 1 Once per JUMPDEST operation.
EpochDuration uint64 30000 Duration between proof-of-work epochs.
CreateDataGas uint64 200
CallCreateDepth uint64 1024 Maximum depth of call/create stack.
ExpGas uint64 10 Once per EXP instruction
LogGas uint64 375 Per LOG* operation.
CopyGas uint64 3
StackLimit uint64 1024 Maximum size of VM stack allowed.
TierStepGas uint64 0 Once per operation, for a selection of them.
LogTopicGas uint64 375 Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas.
CreateGas uint64 32000 Once per CREATE operation & contract-creation transaction.
Create2Gas uint64 32000 Once per CREATE2 operation
SelfdestructRefundGas uint64 24000 Refunded following a selfdestruct operation.
MemoryGas uint64 3 Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL.
TxDataNonZeroGasFrontier uint64 68 Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
TxDataNonZeroGasEIP2028 uint64 16 Per byte of non zero data attached to a transaction after EIP 2028 (part in Istanbul)
TxAccessListAddressGas uint64 2400 Per address specified in EIP 2930 access list
TxAccessListStorageKeyGas uint64 1900 Per storage key specified in EIP 2930 access list
CallGasFrontier uint64 40 Once per CALL operation & message call transaction.
CallGasEIP150 uint64 700 Static portion of gas for CALL-derivates after EIP 150 (Tangerine)
BalanceGasFrontier uint64 20 The cost of a BALANCE operation
BalanceGasEIP150 uint64 400 The cost of a BALANCE operation after Tangerine
BalanceGasEIP1884 uint64 700 The cost of a BALANCE operation after EIP 1884 (part of Istanbul)
ExtcodeSizeGasFrontier uint64 20 Cost of EXTCODESIZE before EIP 150 (Tangerine)
ExtcodeSizeGasEIP150 uint64 700 Cost of EXTCODESIZE after EIP 150 (Tangerine)
SloadGasFrontier uint64 50
SloadGasEIP150 uint64 200
SloadGasEIP1884 uint64 800 Cost of SLOAD after EIP 1884 (part of Istanbul)
SloadGasEIP2200 uint64 800 Cost of SLOAD after EIP 2200 (part of Istanbul)
ExtcodeHashGasConstantinople uint64 400 Cost of EXTCODEHASH (introduced in Constantinople)
ExtcodeHashGasEIP1884 uint64 700 Cost of EXTCODEHASH after EIP 1884 (part in Istanbul)
SelfdestructGasEIP150 uint64 5000 Cost of SELFDESTRUCT post EIP 150 (Tangerine)
GasLimitBoundDivisor uint64 1024 The bound divisor of the gas limit, used in update calculations.
MinGasLimit uint64 5000 Minimum the gas limit may ever be.
MaxGasLimit uint64 0x7fffffffffffffff Maximum the gas limit (2^63-1).
GenesisGasLimit uint64 4712388 Gas limit of the Genesis block.
MaximumExtraDataSize uint64 32 Maximum size extra data may be after Genesis.
ExpByteGas uint64 10 Times ceil(log256(exponent)) for the EXP instruction.
SloadGas uint64 50 Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added.
CallValueTransferGas uint64 9000 Paid for CALL when the value transfer is non-zero.
CallNewAccountGas uint64 25000 Paid for CALL when the destination address didn't exist prior.
TxGas uint64 21000 Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions.
TxGasContractCreation uint64 53000 Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions.
TxDataZeroGas uint64 4 Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions.
QuadCoeffDiv uint64 512 Divisor for the quadratic particle of the memory cost equation.
LogDataGas uint64 8 Per byte in a LOG* operation's data.
CallStipend uint64 2300 Free gas given at beginning of call.
Keccak256Gas uint64 30 Once per KECCAK256 operation.
Keccak256WordGas uint64 6 Once per word of the KECCAK256 operation's data.
SstoreSetGas uint64 20000 Once per SSTORE operation.
SstoreResetGas uint64 5000 Once per SSTORE operation if the zeroness changes from zero.
SstoreClearGas uint64 5000 Once per SSTORE operation if the zeroness doesn't change.
SstoreRefundGas uint64 15000 Once per SSTORE operation if the zeroness changes to zero.
NetSstoreNoopGas uint64 200 Once per SSTORE operation if the value doesn't change.
NetSstoreInitGas uint64 20000 Once per SSTORE operation from clean zero.
NetSstoreCleanGas uint64 5000 Once per SSTORE operation from clean non-zero.
NetSstoreDirtyGas uint64 200 Once per SSTORE operation from dirty.
NetSstoreClearRefund uint64 15000 Once per SSTORE operation for clearing an originally existing storage slot
NetSstoreResetRefund uint64 4800 Once per SSTORE operation for resetting to the original non-zero value
NetSstoreResetClearRefund uint64 19800 Once per SSTORE operation for resetting to the original zero value
SstoreSentryGasEIP2200 uint64 2300 Minimum gas required to be present for an SSTORE call, not consumed
SstoreSetGasEIP2200 uint64 20000 Once per SSTORE operation from clean zero to non-zero
SstoreResetGasEIP2200 uint64 5000 Once per SSTORE operation from clean non-zero to something else
SstoreClearsScheduleRefundEIP2200 uint64 15000 Once per SSTORE operation for clearing an originally existing storage slot
ColdAccountAccessCostEIP2929 uint64(2600) COLD_ACCOUNT_ACCESS_COST
ColdSloadCostEIP2929 uint64(2100) COLD_SLOAD_COST
WarmStorageReadCostEIP2929 uint64(100) WARM_STORAGE_READ_COST

EIP-2930: Optional Access List transactions

source, @fvictorio/gas-costs-after-berlin#EIP-2930-Optional-Access-List-transactions

This EIP adds a new type of transaction that can include an access list in the transaction payload. This means that you can declare beforehand which addresses and slots should be considered as accessed before the transaction’s execution starts. For example, an SLOAD of a non-accessed slot costs 2100, but if that slot was included in the transaction’s access list, then that same opcode will cost 100.

But if the gas costs are lower when an address or storage key is already accessed, does this mean that we can add everything to the transaction’s access list and get a gas reduction? Yay, free gas! Well, not exactly, because you also need to pay gas for each address and each storage key that you add.

Let’s see an example. Say we are sending a transaction to contract A. An access list could look like this:

accessList: [{
  address: "<address of A>",
  storageKeys: [
    "0x0000000000000000000000000000000000000000000000000000000000000000"
  ]
}]

If we send a transaction with this access list, and the first opcode that uses the 0x0 slot is a SLOAD, it will cost 100 instead of 2100. That’s a gas reduction of 2000. But each storage key included in the transaction’s access list has a cost of 1900. So we only save 100 of gas. (If the first opcode to access that slot is an SSTORE instead, we would save 2100 of gas, which means that we’d save 200 of gas in total if we consider the cost of the storage key.)

You always pay gas for the address in the access list ("

" in the example).

Accessed addresses

So far, we’ve been talking only about the SLOAD and SSTORE opcodes, but those aren’t the only ones that change after Berlin. For example, the CALL opcode had a fixed cost of 700. But after EIP-2929 its cost is 2600 if the address is not in the access list and 100 if it is. And, like the accessed storage keys, it doesn’t matter what OPCODE accessed that address before (for example, if an EXTCODESIZE was called first, then that opcode will cost 2600, and any subsequent EXTCODESIZE, CALL, STATICCALL that uses the same address will cost 100).

How is this affected by transactions with access lists? For example, if we send a transaction to contract A, and that contract calls another contract B, then we can include an access list like this:

accessList: [{ address: "<address of B>", storageKeys: [] }]

We’ll have to pay a cost of 2400 to include this access list in the transaction, but then the first opcode that uses the address of B will cost 100 instead of 2600. So we saved 100 of gas by doing this. And if B uses its storage somehow and we know which keys it will use, then we can also include them in the access list and save 100/200 of gas for each one (depending on whether the first opcode is an SLOAD or an SSTORE).

But why are we talking about another contract? What happens with the contract that we are calling? Why don’t we do this?

accessList: [
  {address: "<address of A>", storageKeys: []},
  {address: "<address of B>", storageKeys: []},
]

We could do it, but it wouldn’t be worth it because EIP-2929 specifies that the address of the contract that is being called (that is, tx.to) is always included in the accessed_addresses list. So we are paying 2400 more for nothing.

Let’s analyze our example of the previous section again:

accessList: [{
  address: "<address of A>",
  storageKeys: [
    "0x0000000000000000000000000000000000000000000000000000000000000000"
  ]
}]

This will actually be wasteful unless we include several storage keys more. If we assume that a storage key is always used first by an SLOAD, then we need at least 24 storage keys just to break even.

As you can imagine, analyzing this and creating an access list by hand is not fun. Luckily, there is a better way.

eth_createAccessList

Geth (starting from version 1.10.2) includes a new eth_createAccessList RPC method that you can use to generate access lists. It is used like eth_estimateGas, but instead of a gas estimation, it returns something like this:

{
  "accessList": [
    {
      "address": "0xb0ee076d7779a6ce152283f009f4c32b5f88756c",
      "storageKeys": [
        "0x0000000000000000000000000000000000000000000000000000000000000000",
        "0x0000000000000000000000000000000000000000000000000000000000000001"
      ]
    }
  ],
  "gasUsed": "0x8496"
}

That is, it gives you the list of addresses and storage keys that will be used by that transaction, plus the gas consumed if the access list is included. (And, like eth_estimateGas, this is an estimation; the list could change when the transaction is actually mined.) But, again, this doesn’t mean that this gas will be lower than the gas used if you just send the same transaction without an access list!

Conclusion

Does this mean that we always save gas when using transaction’s with access lists? No.

Gas Fee Speed Definitions

  • Fastest: next block (i.e. <30 seconds)
  • Fast: below 2 minutes (<10 blocks)
  • Medium: around 5 minutes (<20 blocks)
  • Slow: below 30 minutes (a.k.a safe-low, <120 blocks)

Gas Reporting Table Format

Gas Reporting from forge test --gas-report

forge snapshot

CONTRACT_NAME:string
Deployment Cost Deployment Size
type:number type:number
Function Name min avg median max # calls
type:string type:number type:number type:number type:number type:number

Gas Snapshot Format

.gas-snapshot

FooTest:testSetFoo() (gas: 64071)
BarTest:testFuzzCurrentBar(uint256) (runs: 256, μ: 408, ~: 423)

JSON-Schema definition

Each test object represents a test function and has the following properties:

key boolean value
name (required) The name of the test function.
gas (optional) The gas used by the test function. This property is required if the test is not a fuzz test.
runs (optional) The number of runs for the test function. This property is required if the test is a fuzz test.
avg (optional) The average gas used across all runs. This property is required if the test is a fuzz test.
median (optional) The median gas used across all runs. This property is required if the test is a fuzz test.

The oneOf constraint ensures that a test object must have either the gas property (for non-fuzz tests) or the runs, avg, and median properties (for fuzz tests).

This JSON Schema describes the structure of the .gas-snapshot file format used by Forge. It allows for both regular tests with a single gas value and fuzz tests with multiple runs and statistical data (average and median gas used).

gas-snapshot

The schema defines an object with a single property tests, which is an array of test objects.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "tests": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the test function"
          },
          "gas": {
            "type": "integer",
            "description": "The gas used by the test function"
          },
          "runs": {
            "type": "integer",
            "description": "The number of runs for the test function (only applicable for fuzz tests)"
          },
          "avg": {
            "type": "integer",
            "description": "The average gas used across all runs (only applicable for fuzz tests)"
          },
          "median": {
            "type": "integer",
            "description": "The median gas used across all runs (only applicable for fuzz tests)"
          }
        },
        "required": [
          "name"
        ],
        "oneOf": [
          {
            "required": [
              "gas"
            ]
          },
          {
            "required": [
              "runs",
              "avg",
              "median"
            ]
          }
        ]
      }
    }
  },
  "required": [
    "tests"
  ]
}

Example output

╭──────────────────────────┬─────────────────┬───────┬────────┬───────┬─────────╮
│ GasMeterFactory contract ┆                 ┆       ┆        ┆       ┆         │
╞══════════════════════════╪═════════════════╪═══════╪════════╪═══════╪═════════╡
│ Deployment Cost          ┆ Deployment Size ┆       ┆        ┆       ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ 35287                    ┆ 206             ┆       ┆        ┆       ┆         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ Function Name            ┆ min             ┆ avg   ┆ median ┆ max   ┆ # calls │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ build                    ┆ 38653           ┆ 38653 ┆ 38653  ┆ 38653 ┆ 15      │
╰──────────────────────────┴─────────────────┴───────┴────────┴───────┴─────────╯

eth_maxPriorityFeePerGas

Definition

https://github.com/ethereum/execution-apis/blob/main/src/eth/fee_market.yaml

The eth_maxPriorityFeePerGas was originally a client specific RPC Method (go-ethereum), it only recently was made part of the official Ethereum JSON-RPC specification. This method was introduced as part of the EIP-1559 (Ethereum Improvement Proposal 1559) transaction pricing mechanism implementation by the go-ethereum team. It is used to retrieve the current maximum priority fee per gas accepted for the network.

You can calculate a default maxPriorityFeePerGas using eth_feeHistory when eth_maxPriorityFeePerGas is not available.

Calculating the current maximum priority fee per gas

The eth_maxPriorityFeePerGas method allows users, wallets, and dApps to query the Ethereum node and obtain the current maximum priority fee per gas.

The priority fee is an additional fee that can be added to a transaction to incentivize miners to prioritize its inclusion in a block. The returned value represents the maximum priority fee per gas in wei, and this value is a dynamic parameter and can change over time depending on network congestion and block builder preferences.

It represents the maximum accepted priority fee at a given moment but does not guarantee that a transaction with that priority fee will be included in the next block. Inclusion depends on various factors such as gas price, gas limit, and transaction competition.

Go-Ethereum Calculation

Client implementations can vary, for example in go-ethereum (geth) it calculates what is the 60th percentile tip over the last 20 blocks by default.

https://github.com/ethereum/go-ethereum/blob/f265cc24b4b17b55b468b315303a3a599fc01d81/eth/ethconfig/config.go#L40-L47

// FullNodeGPO contains default gasprice oracle settings for full node.
var FullNodeGPO = gasprice.Config{
	Blocks:           20,
	Percentile:       60,
	MaxHeaderHistory: 1024,
	MaxBlockHistory:  1024,
	MaxPrice:         gasprice.DefaultMaxPrice,
	Igno

Usage:

To use this method, you need to send a JSON-RPC request to an Ethereum node with the method name eth_maxPriorityFeePerGas.

The request does not require any parameters.

eth_feeHistory

Definition

https://github.com/ethereum/execution-apis/blob/main/src/eth/fee_market.yaml

eth_feeHistory returns transaction base fee per gas and effective priority fee per gas for the requested/supported block range.

The request does require the following parameters:

blockCount: Requested range of blocks. Clients will return less than the requested range if not all blocks are available.
rewardPercentiles: A monotonically increasing list of percentile values. For each block in the requested range, the transactions will be sorted in ascending order by effective tip per gas and the corresponding effective tip for the percentile will be determined, accounting for gas consumed.
gasUsedRatio: An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit.

Gas Pricing API Providers and Oracles

Listed in no particular order.

Notice: GasNow as of 2021-10-01 will be shutting down due to SparkPools closure

Blocknative

@note there are two seperate entries

gas.blocknative.com

Note: This is powered by Blocknative's global mempool data platform

v2 Blocknative

{
    "system": "ethereum",
    "network": "main",
    "unit": "gwei",
    "maxPrice": 50,
    "currentBlockNumber": 15326495,
    "msSinceLastBlock": 40251,
    "blockPrices": [
        {
            "blockNumber": 15326496,
            "estimatedTransactionCount": 322,
            "baseFeePerGas": 11.075381056,
            "estimatedPrices": [
                {
                    "confidence": 99,
                    "price": 13,
                    "maxPriorityFeePerGas": 2.49,
                    "maxFeePerGas": 22.45
                },
                {
                    "confidence": 95,
                    "price": 13,
                    "maxPriorityFeePerGas": 2.13,
                    "maxFeePerGas": 22.09
                },
                {
                    "confidence": 90,
                    "price": 12,
                    "maxPriorityFeePerGas": 1.92,
                    "maxFeePerGas": 21.88
                },
                {
                    "confidence": 80,
                    "price": 12,
                    "maxPriorityFeePerGas": 1.68,
                    "maxFeePerGas": 21.64
                },
                {
                    "confidence": 70,
                    "price": 12,
                    "maxPriorityFeePerGas": 1.58,
                    "maxFeePerGas": 21.54
                }
            ]
        }
    ],
    "estimatedBaseFees": [
        {
            "pending+1": [
                {
                    "confidence": 99,
                    "baseFee": 12.46
                }
            ]
        },
        {
            "pending+2": [
                {
                    "confidence": 99,
                    "baseFee": 14.02
                }
            ]
        },
        {
            "pending+3": [
                {
                    "confidence": 99,
                    "baseFee": 15.77
                }
            ]
        },
        {
            "pending+4": [
                {
                    "confidence": 99,
                    "baseFee": 17.75
                }
            ]
        },
        {
            "pending+5": [
                {
                    "confidence": 99,
                    "baseFee": 19.96
                }
            ]
        }
    ]
}

v1 Blocknative

{
  "system": "ethereum",
  "network": "main",
  "unit": "gwei",
  "maxPrice": 336,
  "currentBlockNumber": 13095949,
  "msSinceLastBlock": 4542,
  "blockPrices": [
    {
      "blockNumber": 13095950,
      "baseFeePerGas": 113.110076547,
      "estimatedTransactionCount": 172,
      "estimatedPrices": [
        {
          "confidence": 99,
          "price": 129,
          "maxPriorityFeePerGas": 15.96,
          "maxFeePerGas": 242.18
        },
        {
          "confidence": 95,
          "price": 119,
          "maxPriorityFeePerGas": 6.84,
          "maxFeePerGas": 233.06
        },
        {
          "confidence": 90,
          "price": 118,
          "maxPriorityFeePerGas": 5.09,
          "maxFeePerGas": 231.31
        },
        {
          "confidence": 80,
          "price": 116,
          "maxPriorityFeePerGas": 3.21,
          "maxFeePerGas": 229.43
        },
        {
          "confidence": 70,
          "price": 115,
          "maxPriorityFeePerGas": 2.28,
          "maxFeePerGas": 228.5
        }
      ]
    }
  ]
}

bnc-ext

BlockNative Chrome Extenstion

blocknative eth gas estimate extenstion

https://blocknative-api.herokuapp.com/data

sample response

{
  "pendingBlockNumberVal": 13378149,
  "seconds": 17,
  "maxPrice": 768,
  "estimatedTransactions": 279,
  "estimatedPrices": [{
    "confidence": 99,
    "price": 86,
    "maxPriorityFeePerGas": 2.96,
    "maxFeePerGas": 170.76
  }, {
    "confidence": 95,
    "price": 85,
    "maxPriorityFeePerGas": 1.75,
    "maxFeePerGas": 169.55
  }, {
    "confidence": 90,
    "price": 85,
    "maxPriorityFeePerGas": 1.56,
    "maxFeePerGas": 169.36
  }, {
    "confidence": 80,
    "price": 85,
    "maxPriorityFeePerGas": 1.48,
    "maxFeePerGas": 169.28
  }, {
    "confidence": 70,
    "price": 85,
    "maxPriorityFeePerGas": 1.37,
    "maxFeePerGas": 169.17
  }],
  "baseFeePerGas": 83.897778652
}

Curve-Finance

getGas

https://api.curve.fi/api/getGas

 https://api.curve.fi/api/getGas
{
    "success": true,
    "data": {
        "gas": {
            "rapid": 36000000000,
            "fast": 35000000000,
            "standard": 35000000000,
            "slow": 35000000000
        },
        "eip1559Gas": {
            "base": 35292604977,
            "prio": [
                1220000000,
                500000000,
                350000000,
                230000000
            ],
            "max": [
                56110000000,
                55390000000,
                55240000000,
                55120000000
            ]
        }
    },
    "generatedTimeMs": 1668181797396
}

WalletConnect

specification

https://github.com/pedrouid/ethereum-api#api

https://ethereum-api.xyz/gas-prices

http GET https://ethereum-api.xyz/gas-prices

sample response

{
  "timestamp": 1633172858972,
  "slow": {
    "time": 756,
    "price": 39
  },
  "average": {
    "time": 84,
    "price": 42
  },
  "fast": {
    "time": 30,
    "price": 54
  },
  "fastest": {
    "time": 24,
    "price": 58
  }
}

Flashbots

eth_gasFee

specification

see source documentation

// prettier-ignore

{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    block,                     // Number, current block number
    baseFeePerGas,             // String, a hex number for the baseFee at the current block
    default: {
      maxFeePerGas,            // String, a hex number for the recommended default maxFeePerGas
      maxPriorityFeePerGas,    // String, a hex number for the recommended default maxPriorityFeePerGas
    },
    low: {
      maxFeePerGas,            // String, a hex number for the recommended low maxFeePerGas
      maxPriorityFeePerGas,    // String, a hex number for the recommended low maxPriorityFeePerGas
    },
    med: {
      maxFeePerGas,            // String, a hex number for the recommended med maxFeePerGas
      maxPriorityFeePerGas,    // String, a hex number for the recommended med maxPriorityFeePerGas
    },
    high: {
      maxFeePerGas,            // String, a hex number for the recommended high maxFeePerGas
      maxPriorityFeePerGas,    // String, a hex number for the recommended high maxPriorityFeePerGas
    },
  }
}

request sample

curl -s -L -X POST 'https://protection.flashbots.net/v1/rpc' \
-H 'Content-Type: application/json' \
--data-raw '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_gasFees",
  "params": []
}'

response

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "block": 13467179,
        "baseFeePerGas": "0x0bd0606957",
        "default": {
            "maxFeePerGas": "0x12ec776ebc",
            "maxPriorityFeePerGas": "0x01e47257df"
        },
        "low": {
            "maxFeePerGas": "0x11d7682749",
            "maxPriorityFeePerGas": "0xe45ecec3"
        },
        "med": {
            "maxFeePerGas": "0x12ec776ebc",
            "maxPriorityFeePerGas": "0x01e47257df"
        },
        "high": {
            "maxFeePerGas": "0x1412552c31",
            "maxPriorityFeePerGas": "0x0302bff9d4"
        }
    }
}

EtherScan

https://docs.etherscan.io/api-endpoints/gas-tracker

https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=YourApiKeyToken

{
  "status": "1",
  "message": "OK",
  "result": {
    "LastBlock": "13053741",
    "SafeGasPrice": "20",
    "ProposeGasPrice": "22",
    "FastGasPrice": "24",
    "suggestBaseFee": "19.230609716",
    "gasUsedRatio": "0.370119078777807,0.8954731,0.550911766666667,0.212457033333333,0.552463633333333"
  }
}

GasNow [no longer in service]

gasnow.org/taichi

wss://www.gasnow.org/ws
{
  "type": "gasprice",
  "data": {
    "gasPrices": {
      "rapid": 67000000000,
      "fast": 64455346560,
      "standard": 63455346560,
      "slow": 63455346560
    },
    "cumulativeCounts": [
      {
        "gwei": "63",
        "cumulativeCount": 93
      },
      {
        "gwei": "64",
        "cumulativeCount": 81
      },
      {
        "gwei": "65",
        "cumulativeCount": 65
      },
      {
        "gwei": "66",
        "cumulativeCount": 35
      },
      {
        "gwei": "67",
        "cumulativeCount": 34
      },
      {
        "gwei": "68",
        "cumulativeCount": 32
      },
      {
        "gwei": "69",
        "cumulativeCount": 30
      },
      {
        "gwei": "70",
        "cumulativeCount": 25
      },
      {
        "gwei": "71",
        "cumulativeCount": 22
      },
      {
        "gwei": "73",
        "cumulativeCount": 21
      },
      {
        "gwei": "74",
        "cumulativeCount": 19
      },
      {
        "gwei": "75",
        "cumulativeCount": 17
      },
      {
        "gwei": "78",
        "cumulativeCount": 16
      },
      {
        "gwei": "80",
        "cumulativeCount": 15
      },
      {
        "gwei": "81",
        "cumulativeCount": 13
      },
      {
        "gwei": "87",
        "cumulativeCount": 12
      },
      {
        "gwei": "88",
        "cumulativeCount": 11
      },
      {
        "gwei": "89",
        "cumulativeCount": 9
      },
      {
        "gwei": "94",
        "cumulativeCount": 8
      },
      {
        "gwei": "96",
        "cumulativeCount": 6
      },
      {
        "gwei": "98",
        "cumulativeCount": 5
      },
      {
        "gwei": "109",
        "cumulativeCount": 4
      },
      {
        "gwei": "112",
        "cumulativeCount": 3
      },
      {
        "gwei": "120",
        "cumulativeCount": 2
      },
      {
        "gwei": "221",
        "cumulativeCount": 1
      }
    ],
    "timestamp": 1629975608579
  }
}

GasNow Legacy

{
  "code": 200,
  "data": {
    "rapid": 131000000000,
    "fast": 116000000000,
    "standard": 100000000000,
    "slow": 91600000000,
    "timestamp": 1613914581546
  }
}

Gnosis

endpoint url

{
  "lastUpdate": "2021-02-21T13:38:38.945308Z",
  "lowest": "2",
  "safeLow": "109000000001",
  "standard": "119000000001",
  "fast": "131000000001",
  "fastest": "10680081443136"
}

MetaMask

Consensys CoDeFi

endpoint url

{
  "low": {
    "suggestedMaxPriorityFeePerGas": "1.37826449268",
    "suggestedMaxFeePerGas": "70.067746222",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 30000
  },
  "medium": {
    "suggestedMaxPriorityFeePerGas": "1.5",
    "suggestedMaxFeePerGas": "81.637728684",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 45000
  },
  "high": {
    "suggestedMaxPriorityFeePerGas": "2",
    "suggestedMaxFeePerGas": "93.585975639",
    "minWaitTimeEstimate": 15000,
    "maxWaitTimeEstimate": 60000
  },
  "estimatedBaseFee": "57.241234774",
   "networkCongestion": 0.5,
}
{
  "SafeGasPrice": "100",
  "ProposeGasPrice": "108",
  "FastGasPrice": "119"
}

1inch

https://gas-price-api.1inch.exchange/v1.0

v1.0

{
  "fast": 96820000000,
  "instant": 125000000000,
  "standard": 90000000000,
  "slow": 82000000000
}

v1.2

gas-price-api.1inch.io/v.1.2

{
    "baseFee": "93731028208",
    "low": {
        "maxPriorityFeePerGas": "1170000000",
        "maxFeePerGas": "94901028208"
    },
    "medium": {
        "maxPriorityFeePerGas": "2340000000",
        "maxFeePerGas": "96071028208"
    },
    "high": {
        "maxPriorityFeePerGas": "5850000000",
        "maxFeePerGas": "99581028208"
    },
    "instant": {
        "maxPriorityFeePerGas": "5850000000",
        "maxFeePerGas": "129455336670"
    }
}

ethGasStation

endpoint url

{
  "fast": 1200.0,
  "fastest": 1200.0,
  "safeLow": 1020.0,
  "average": 1050.0,
  "block_time": 13.327868852459016,
  "blockNum": 11900622,
  "speed": 0.997822721438169,
  "safeLowWait": 12.9,
  "avgWait": 1.5,
  "fastWait": 0.5,
  "fastestWait": 0.5,
  "gasPriceRange": {
    "1200": 0.5,
    "1180": 0.5,
    "1160": 0.6,
    "1140": 0.6,
    "1120": 0.7,
    "1100": 0.7,
    "1080": 1.2,
    "1060": 1.5,
    "1040": 11.5,
    "1020": 12.9,
    "1000": 14.3,
    "980": 17.4,
    "960": 18.9,
    "940": 21.1,
    "920": 222.1,
    "900": 222.1,
    "880": 222.1,
    "860": 222.1,
    "840": 222.1,
    "820": 222.1,
    "800": 222.1,
    "780": 222.1,
    "760": 222.1,
    "740": 222.1,
    "720": 222.1,
    "700": 222.1,
    "680": 222.1,
    "660": 222.1,
    "640": 222.1,
    "620": 222.1,
    "600": 222.1,
    "580": 222.1,
    "560": 222.1,
    "540": 222.1,
    "520": 222.1,
    "500": 222.1,
    "480": 222.1,
    "460": 222.1,
    "440": 222.1,
    "420": 222.1,
    "400": 222.1,
    "380": 222.1,
    "360": 222.1,
    "340": 222.1,
    "320": 222.1,
    "300": 222.1,
    "280": 222.1,
    "260": 222.1,
    "240": 222.1,
    "220": 222.1,
    "200": 222.1,
    "190": 222.1,
    "180": 222.1,
    "170": 222.1,
    "160": 222.1,
    "150": 222.1,
    "140": 222.1,
    "130": 222.1,
    "120": 222.1,
    "110": 222.1,
    "100": 222.1,
    "90": 222.1,
    "80": 222.1,
    "70": 222.1,
    "60": 222.1,
    "50": 222.1,
    "40": 222.1,
    "30": 222.1,
    "20": 222.1,
    "10": 222.1,
    "8": 222.1,
    "6": 222.1,
    "4": 222.1,
    "1050": 1.5
  }
}
{
  "fast": 1200.0,
  "fastest": 1200.0,
  "safeLow": 1020.0,
  "average": 1050.0,
  "block_time": 13.327868852459016,
  "blockNum": 11900622,
  "speed": 0.997822721438169,
  "safeLowWait": 12.9,
  "avgWait": 1.5,
  "fastWait": 0.5,
  "fastestWait": 0.5,
  "gasPriceRange": {
    "1200": 0.5,
    "1180": 0.5,
    "1160": 0.6,
    "1140": 0.6,
    "1120": 0.7,
    "1100": 0.7,
    "1080": 1.2,
    "1060": 1.5,
    "1040": 11.5,
    "1020": 12.9,
    "1000": 14.3,
    "980": 17.4,
    "960": 18.9,
    "940": 21.1,
    "920": 222.1,
    "900": 222.1,
    "880": 222.1,
    "860": 222.1,
    "840": 222.1,
    "820": 222.1,
    "800": 222.1,
    "780": 222.1,
    "760": 222.1,
    "740": 222.1,
    "720": 222.1,
    "700": 222.1,
    "680": 222.1,
    "660": 222.1,
    "640": 222.1,
    "620": 222.1,
    "600": 222.1,
    "580": 222.1,
    "560": 222.1,
    "540": 222.1,
    "520": 222.1,
    "500": 222.1,
    "480": 222.1,
    "460": 222.1,
    "440": 222.1,
    "420": 222.1,
    "400": 222.1,
    "380": 222.1,
    "360": 222.1,
    "340": 222.1,
    "320": 222.1,
    "300": 222.1,
    "280": 222.1,
    "260": 222.1,
    "240": 222.1,
    "220": 222.1,
    "200": 222.1,
    "190": 222.1,
    "180": 222.1,
    "170": 222.1,
    "160": 222.1,
    "150": 222.1,
    "140": 222.1,
    "130": 222.1,
    "120": 222.1,
    "110": 222.1,
    "100": 222.1,
    "90": 222.1,
    "80": 222.1,
    "70": 222.1,
    "60": 222.1,
    "50": 222.1,
    "40": 222.1,
    "30": 222.1,
    "20": 222.1,
    "10": 222.1,
    "8": 222.1,
    "6": 222.1,
    "4": 222.1,
    "1050": 1.5
  }
}

etherchain.org

endpoint url

{"safeLow":1,"standard":1,"fast":1.5,"fastest":2,"currentBaseFee":72.5,"recommendedBaseFee":147.2}
{ "safeLow": 102, "standard": 105, "fast": 114.6, "fastest": 120 }

etherchain-gasnow

https://etherchain.org/api/gasnow

{code: 200, data: {rapid: 60000000000, fast: 39962373278, standard: 24406984375, slow: 19550000000,}}
code: 200
data: {rapid: 60000000000, fast: 39962373278, standard: 24406984375, slow: 19550000000,}
fast: 39962373278
priceUSD: 1818.52
rapid: 60000000000
slow: 19550000000
standard: 24406984375
timestamp: 1654245505826

Response

{"code":200,"data":{"rapid":65265049007,"fast":49988581398,"standard":23000000000,"slow":19550000000,"timestamp":1654245243247,"priceUSD":1818.52}}

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$id": "etherchain_gasnow",
  "type": "object",
  "properties": {
    "code": {
      "type": "integer"
    },
    "data": {
      "type": "object",
      "properties": {
        "rapid": {
          "type": "integer"
        },
        "fast": {
          "type": "integer"
        },
        "standard": {
          "type": "integer"
        },
        "slow": {
          "type": "integer"
        },
        "timestamp": {
          "type": "integer"
        },
        "priceUSD": {
          "type": "number"
        }
      },
      "required": [
        "rapid",
        "fast",
        "standard",
        "slow",
        "timestamp",
        "priceUSD"
      ]
    }
  },
  "required": [
    "code",
    "data"
  ]
}

poanetwork

endpoint url

{
  "health": true,
  "block_number": 11900628,
  "slow": 101.0,
  "standard": 107.0,
  "fast": 115.0,
  "instant": 130.8,
  "block_time": 13.191
}
{
  "health": true,
  "block_number": 11900628,
  "slow": 101.0,
  "standard": 107.0,
  "fast": 115.0,
  "instant": 130.8,
  "block_time": 13.191
}

Zoltu

nanoeth is the SI nomenclature for gwei

{
  "number_of_blocks": 200,
  "latest_block_number": 11907178,
  "percentile_1": "1e-9 nanoeth",
  "percentile_2": "0.00001 nanoeth",
  "percentile_3": "0.000011001 nanoeth",
  "percentile_4": "1 nanoeth",
  "percentile_5": "6 nanoeth",
  "percentile_10": "10 nanoeth",
  "percentile_15": "152 nanoeth",
  "percentile_20": "170 nanoeth",
  "percentile_25": "181.5 nanoeth",
  "percentile_30": "190.000001459 nanoeth",
  "percentile_35": "200 nanoeth",
  "percentile_40": "214.76 nanoeth",
  "percentile_45": "222.814063547 nanoeth",
  "percentile_50": "229.9 nanoeth",
  "percentile_55": "232 nanoeth",
  "percentile_60": "245 nanoeth",
  "percentile_65": "256 nanoeth",
  "percentile_70": "262 nanoeth",
  "percentile_75": "270.6 nanoeth",
  "percentile_80": "278 nanoeth",
  "percentile_85": "289.02 nanoeth",
  "percentile_90": "300 nanoeth",
  "percentile_95": "314.4 nanoeth",
  "percentile_96": "315.21 nanoeth",
  "percentile_97": "316.075841562 nanoeth",
  "percentile_98": "325 nanoeth",
  "percentile_99": "326 nanoeth",
  "percentile_100": "348 nanoeth"
}

MyCrypto

{
  "safeLow": 159,
  "standard": 184,
  "fast": 262,
  "fastest": 289,
  "blockNum": 11907235
}
{
  "safeLow": 159,
  "standard": 184,
  "fast": 262,
  "fastest": 289,
  "blockNum": 11907235
}

EtherScan

api endpoint key required

{
  "status": "1",
  "message": "OK",
  "result": {
    "LastBlock": "11907242",
    "SafeGasPrice": "248",
    "ProposeGasPrice": "269",
    "FastGasPrice": "294"
  }
}
{
  "status": "1",
  "message": "OK",
  "result": {
    "LastBlock": "11907242",
    "SafeGasPrice": "248",
    "ProposeGasPrice": "269",
    "FastGasPrice": "294"
  }
}

Zapper

http://api.zapper.fi/v1/gas-price

{
  "standard": 113,
  "fast": 114,
  "instant": 136
}

archerdao

https://api.archerdao.io/v1/gas

{
  "code": 200,
  "data": {
    "immediate": "228202648099",
    "rapid": "67236905683",
    "fast": "13591066085",
    "standard": "1101380018",
    "slow": "0",
    "slower": "0",
    "slowest": "0"
  }
}

gas-ticker

Gas Ticker by ricmoo

{
  "blockNumber": 14610954,
  "timestamp": 1650309194.438,
  "slow": {
    "min": 29.397486945,
    "max": 70.143180307,
    "sum": 13465.490242759988,
    "count": 385,
    "mean": 34.97529933184413,
    "median": 35,
    "tp90": 38,
    "stdDev": 5.992331436594249,
    "target90": 37.265690661,
    "targetStdDev": 2.7612260317587007,
    "targetCount": 266,
    "targetBest": 30,
    "targetWorst": 39.532494062
  },
  "medium": {
    "min": 29.397486945,
    "max": 62.428616398,
    "sum": 29594.27666106807,
    "count": 680,
    "mean": 43.520995089805986,
    "median": 39.038827568,
    "tp90": 52.433561707,
    "stdDev": 8.816041449214934,
    "target90": 50,
    "targetStdDev": 4.467921632212077,
    "targetCount": 470,
    "targetBest": 34.911631032,
    "targetWorst": 52.3082
  },
  "fast": {
    "min": 29.397486945,
    "max": 1200.988196226,
    "sum": 753432.9418861985,
    "count": 14637,
    "mean": 51.47454682559257,
    "median": 48.554602972,
    "tp90": 59.570121624,
    "stdDev": 24.12932660961557,
    "target90": 60.216413805,
    "targetStdDev": 6.10997036680254,
    "targetCount": 10100,
    "targetBest": 38.822145579,
    "targetWorst": 64.139501286
  }
}

Appendix

Custom Network Over pricing

Metamask will pad the estimated gas without exceeding the most recent block gasLimit. However, If the network is a a custom network it will return the eth_estimateGas value

see metamask/controllers

URL Index

Current offchain list:

EVM Params

Key Value Description
JumpdestGas uint64 1 Once per JUMPDEST operation.
EpochDuration uint64 30000 Duration between proof-of-work epochs.
CreateDataGas uint64 200
CallCreateDepth uint64 1024 Maximum depth of call/create stack.
ExpGas uint64 10 Once per EXP instruction
LogGas uint64 375 Per LOG* operation.
CopyGas uint64 3
StackLimit uint64 1024 Maximum size of VM stack allowed.
TierStepGas uint64 0 Once per operation, for a selection of them.
LogTopicGas uint64 375 Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas.
CreateGas uint64 32000 Once per CREATE operation & contract-creation transaction.
Create2Gas uint64 32000 Once per CREATE2 operation
SelfdestructRefundGas uint64 24000 Refunded following a selfdestruct operation.
MemoryGas uint64 3 Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL.
TxDataNonZeroGasFrontier uint64 68 Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
TxDataNonZeroGasEIP2028 uint64 16 Per byte of non zero data attached to a transaction after EIP 2028 (part in Istanbul)
TxAccessListAddressGas uint64 2400 Per address specified in EIP 2930 access list
TxAccessListStorageKeyGas uint64 1900 Per storage key specified in EIP 2930 access list
CallGasFrontier uint64 40 Once per CALL operation & message call transaction.
CallGasEIP150 uint64 700 Static portion of gas for CALL-derivates after EIP 150 (Tangerine)
BalanceGasFrontier uint64 20 The cost of a BALANCE operation
BalanceGasEIP150 uint64 400 The cost of a BALANCE operation after Tangerine
BalanceGasEIP1884 uint64 700 The cost of a BALANCE operation after EIP 1884 (part of Istanbul)
ExtcodeSizeGasFrontier uint64 20 Cost of EXTCODESIZE before EIP 150 (Tangerine)
ExtcodeSizeGasEIP150 uint64 700 Cost of EXTCODESIZE after EIP 150 (Tangerine)
SloadGasFrontier uint64 50
SloadGasEIP150 uint64 200
SloadGasEIP1884 uint64 800 Cost of SLOAD after EIP 1884 (part of Istanbul)
SloadGasEIP2200 uint64 800 Cost of SLOAD after EIP 2200 (part of Istanbul)
ExtcodeHashGasConstantinople uint64 400 Cost of EXTCODEHASH (introduced in Constantinople)
ExtcodeHashGasEIP1884 uint64 700 Cost of EXTCODEHASH after EIP 1884 (part in Istanbul)
SelfdestructGasEIP150 uint64 5000 Cost of SELFDESTRUCT post EIP 150 (Tangerine)
GasLimitBoundDivisor uint64 1024 The bound divisor of the gas limit, used in update calculations.
MinGasLimit uint64 5000 Minimum the gas limit may ever be.
MaxGasLimit uint64 0x7fffffffffffffff Maximum the gas limit (2^63-1).
GenesisGasLimit uint64 4712388 Gas limit of the Genesis block.
MaximumExtraDataSize uint64 32 Maximum size extra data may be after Genesis.
ExpByteGas uint64 10 Times ceil(log256(exponent)) for the EXP instruction.
SloadGas uint64 50 Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added.
CallValueTransferGas uint64 9000 Paid for CALL when the value transfer is non-zero.
CallNewAccountGas uint64 25000 Paid for CALL when the destination address didn't exist prior.
TxGas uint64 21000 Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions.
TxGasContractCreation uint64 53000 Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions.
TxDataZeroGas uint64 4 Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions.
QuadCoeffDiv uint64 512 Divisor for the quadratic particle of the memory cost equation.
LogDataGas uint64 8 Per byte in a LOG* operation's data.
CallStipend uint64 2300 Free gas given at beginning of call.
Keccak256Gas uint64 30 Once per KECCAK256 operation.
Keccak256WordGas uint64 6 Once per word of the KECCAK256 operation's data.
SstoreSetGas uint64 20000 Once per SSTORE operation.
SstoreResetGas uint64 5000 Once per SSTORE operation if the zeroness changes from zero.
SstoreClearGas uint64 5000 Once per SSTORE operation if the zeroness doesn't change.
SstoreRefundGas uint64 15000 Once per SSTORE operation if the zeroness changes to zero.
NetSstoreNoopGas uint64 200 Once per SSTORE operation if the value doesn't change.
NetSstoreInitGas uint64 20000 Once per SSTORE operation from clean zero.
NetSstoreCleanGas uint64 5000 Once per SSTORE operation from clean non-zero.
NetSstoreDirtyGas uint64 200 Once per SSTORE operation from dirty.
NetSstoreClearRefund uint64 15000 Once per SSTORE operation for clearing an originally existing storage slot
NetSstoreResetRefund uint64 4800 Once per SSTORE operation for resetting to the original non-zero value
NetSstoreResetClearRefund uint64 19800 Once per SSTORE operation for resetting to the original zero value
SstoreSentryGasEIP2200 uint64 2300 Minimum gas required to be present for an SSTORE call, not consumed
SstoreSetGasEIP2200 uint64 20000 Once per SSTORE operation from clean zero to non-zero
SstoreResetGasEIP2200 uint64 5000 Once per SSTORE operation from clean non-zero to something else
SstoreClearsScheduleRefundEIP2200 uint64 15000 Once per SSTORE operation for clearing an originally existing storage slot
ColdAccountAccessCostEIP2929 uint64(2600) COLD_ACCOUNT_ACCESS_COST
ColdSloadCostEIP2929 uint64(2100) COLD_SLOAD_COST
WarmStorageReadCostEIP2929 uint64(100) WARM_STORAGE_READ_COST