question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gas price engine API

See original GitHub issue

What was wrong?

Currently, web3.py just uses the eth_gasPrice JSON-RPC API to determine the gas price to use for transactions. Most nodes do not currently implement very good algorithms for determining gas prices.

How can it be fixed?

Lets implement a new API for determining gas prices.

  • Add a new API: Web3.set_gas_price_engine(engine)
  • Add new API: Web3.get_gas_price(transaction_params) which delegates to whatever engine is set.

An engine must be a callable with the function signature:

engine(w3, transaction_params)
  • w3 will be the Web3 instance
  • transaction_params will be a dictionary of the transaction params being sent.

The callable must return a positive integer which represents the gas_price in the wei denomination.

The default engine that a web3 instance should use is one that simply returns web3.eth.gasPrice

Documentation should be added covering the following topics.

  • Overview of the Web3.set_gas_price_engine() API (maybe in docs/overview.rst)
  • Writing your own gas price engine (maybe in new document docs/gas_pricing_engine.rst or docs/web3.main.rst)
  • List of available engines, where to import them and how to use them.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pipermerriamcommented, Dec 26, 2017

@monokh etherscan.io/tx/0x20718ee637c2c01dfab0c7c0e9747f50512ef934e94462f077ced545d8926683

1reaction
pipermerriamcommented, Dec 13, 2017

@monokh take a look at #496 which builds on top of the API suggested in this PR and is a simplified version of the EGS algorithm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gas Prices API - CollectAPI
Reach gasoline and diesel prices in different fuel stations in different cities. This API can using free.
Read more >
Gas prices API : r/api - Reddit
Anyone know of any APIs for gas prices? I found this one https://collectapi.com/api/gasPrice/gas-prices-api but it only has 100 calls a ...
Read more >
Introduction | Fuel Prices API - TomTom Developer Portal
The Fuel Prices API provides information about the current price of the fuel available at the selected station. The data is refreshed every...
Read more >
Gas Prices Explained - American Petroleum Institute
Digging into Crude Oil, Gasoline and Natural Gas Prices 3.0​​ API Chief Economist Dean Foreman explains what's behind rising gas prices, including the...
Read more >
Petroleum Data: Prices Application Programming Interface (API)
Prices of petroleum products and crude oil. Weekly, monthly, and annual data available. Users of the EIA API are required to obtain an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found