-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web3.eth.gasPrice is returning incorrect value #1230
Comments
+1 |
+1 Happening to me as well. Right now, https://ethgasstation.info/ reports |
@prashantprabhakar This is not a issue of web3.js because it gets the value from the node. The problem is that gas station does calculate it differently than geth. |
@nivida This was not a comparison of eth gas station. I checked the txs on etherscan and last few blocks were using gas of 60Gwei but web3.eth.gasPrice was returning 21 wei. |
did you try the below? I use the below but I suspect it also gives low gas price here I use |
@prashantprabhakar This happens because the gas price is determined by the x latest blocks median gas price from the current connected node. I would use the https://ethgasstation.info/ API if you really want to have an exact current gas price. The long term goal will be to improve the |
As mentioned in documentation eth.gasPrice returns the current gas price. The gas price is determined by the x latest blocks median gas price.
But recently( 3 days ago), the ethereum network was congested and gas price increased to 60 GWei. But web3.eth.gasPrice was returning 21000000000 (21 Gwei).
I also checked some recent transactions on etherscan : 0xf5ccc6ecc36b318c8ac9794e2b472fa2f9b3acc0b2adf662b4f858b76a69c278, 0x123789fd42ad2037fff8bfaca3caeb6bec179b4630588902ae95c9515c742432, 0xf78960adb886d9a31549a04154ce459e00896dac6c7156e749c63f6755c5a4c9
All of them has the gas price of 60 Gwei. So why is eth.gasPrice is giving me 21GWei? I was relying on web3.eth.gasPrice function to get current safe gas price, but this doesn't seem to work normally.
The text was updated successfully, but these errors were encountered: