Day153 — get maxPriorityFeePerGas and maxFeePerGas

Jacky Tsang
1 min readJul 17, 2022

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();

--

--