Skip to content

Instantly share code, notes, and snippets.

@staccDOTsol
Created July 14, 2021 02:50
Show Gist options
  • Save staccDOTsol/995da23b9b9b310314ef1aee0427abfb to your computer and use it in GitHub Desktop.
Save staccDOTsol/995da23b9b9b310314ef1aee0427abfb to your computer and use it in GitHub Desktop.
from web3 import Web3
from web3 import middleware
from web3.gas_strategies.time_based import medium_gas_price_strategy, fast_gas_price_strategy, slow_gas_price_strategy
from web3.gas_strategies.rpc import rpc_gas_price_strategy
w3= Web3(Web3.HTTPProvider("https://mainnet.infura.io/v3/yourkey", request_kwargs={'timeout': 60}))
w3.eth.setGasPriceStrategy(rpc_gas_price_strategy)
print('RPC:', w3.eth.generateGasPrice())
w3.eth.setGasPriceStrategy(slow_gas_price_strategy)
print('Slow', w3.eth.generateGasPrice())
w3.eth.setGasPriceStrategy(medium_gas_price_strategy)
print('Medium:', w3.eth.generateGasPrice())
w3.eth.setGasPriceStrategy(fast_gas_price_strategy)
print('Fast:', w3.eth.generateGasPrice())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment