Skip to main content

How to retrive a dynamic average value for gas-price

I'm wondering how can I get the correct current average gas price ( or the new parameters maxPriorityFeePerGas and maxFeePerGas ) to push to my web3 wallet in order to have my transaction mined?

I know that there is an rpc call that you make that returns the current gasPrice of the rpc node you are calling, but it always seems not dynamic, by dynamic I mean that i'd like the value to change over time to match the real variation of gasPrice used by transactions of the latest blocks.

I mean, in a self hosted geth node, there is a way for retriving a dynamic value for this attributes? they seems like hardcoded and never get updated, for example from the GETH cli eth.gasPrice , eth.maxPriorityFeePerGas returns always 1000000000 why is that? do i have to implement myself a tracker that based on the latest 'x' blocks it returns the average gasPrice used or does geth have an internal logic that already does this that I can call ? Thanks in advance :)

Mat.C
  • 176
  • 1
  • 1
  • 6