When sending a TX, there's an optional gasPrice field. If I don't set it, what's it default to? Does it look at other TXs going on or is it a fixed value that only changes when web3 gets updated to a new version? Is there a way to get the default value so that I can, for example, add 1gwei to it? I'd like to ensure order of TXs in the same block by paying more for the first TX.
Asked
Active
Viewed 6,638 times
1 Answers
4
There is a web3.eth.gasPrice function. From the documentation (https://web3js.readthedocs.io/en/1.0/web3-eth.html#eth-gasprice):
The gas price is determined by the last few blocks median gas price.
So the gas price defaults to this value. You can of course change it but it doesn't make sense to try to order the txs with the gas price. Besides there is no way to ensure that txs you send end up in the same block.
lunr
- 808
- 8
- 13
web3.eth.gasPriceI had to useweb3.eth.getGasPrice()which is a promise that returns the median gas price. – Ahmed Akhtar Sep 01 '19 at 19:43