Get Gas Parameters
The gasParameters
allows you to fetch recommended fees and gas information directly from the node. This is more reliable than using fixed values.
Method
const gasParameters = await provider.gasParameters();
The returned object includes:
blockNumber
– The current block number of the network.gasUsed
– Amount of gas used in the last block.targetGasLimit
– Target gas limit for blocks.ema
– Exponential moving average for gas metrics.baseGas
– Base gas value used for fee calculations.gasPerSat
– Gas price per satoshi.bitcoin.conservative
– Conservative Bitcoin fee rate suggestion.bitcoin.recommended.low
– Suggested fee rate for low-priority transactions.bitcoin.recommended.medium
– Suggested fee rate for standard transactions.bitcoin.recommended.high
– Suggested fee rate for high-priority transactions.
What’s Next?
After fetching block gas parameters, you can: