Day153 — get maxPriorityFeePerGas and maxFeePerGas

I did a project that involves getting the estimated gas for a EIP-1559 transaction so that it could proceed smoothly.

In the ethers.js library, it provides a method getFeeData() to get the estimated gas, which is maxPriorityFeePerGas and maxFeePerGas .

but as you can see, the maxPriorityFeePerGas is hardcoded as 1500000000 wei (1.5 gwei). That is not ideal.

To get the maxPriorityFeePerGas, a custom rpc method is called

await provider.send("eth_maxPriorityFeePerGas", [])

referencing below in alchemy-web3

const fee = await web3.eth.getMaxPriorityFeePerGas();

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store