Gas price engine API
See original GitHub issueWhat 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 theWeb3
instancetransaction_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 indocs/overview.rst
) - Writing your own gas price engine (maybe in new document
docs/gas_pricing_engine.rst
ordocs/web3.main.rst
) - List of available engines, where to import them and how to use them.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@monokh etherscan.io/tx/0x20718ee637c2c01dfab0c7c0e9747f50512ef934e94462f077ced545d8926683
@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.