How is Ethereum gas calculated under EIP-1559?
Ethereum EIP-1559 gas fees equal gas used times the base fee plus tip, capped by maxFeePerGas; see how to set fee fields and calculate a swap’s cost.
The Splyt Genesis Desk

Ethereum gas fees under EIP-1559 equal the gas used multiplied by the effective gas price, which is the base fee plus your priority fee up to your maxFeePerGas. The London upgrade introduced this split in August 2021: the protocol sets and burns the base fee, while the priority fee goes to the block producer.
How does EIP-1559 calculate the fee?
For a type-2 transaction, calculate the effective gas price as the lower of maxFeePerGas and the base fee plus maxPriorityFeePerGas. Then multiply that price by the gas the transaction actually uses. Divide the result in gwei by 1 billion to get the fee in ETH, since 1 gwei is 10-9 ETH.
For instance, if a transaction uses 150,000 gas at a 20 gwei base fee with a 1 gwei priority fee, its effective price is 21 gwei. The total is 3,150,000 gwei, or 0.00315 ETH. If maxFeePerGas is 50 gwei, the remaining 29 gwei per unit is not charged; the cap sets a ceiling, not the price.
The base fee changes with network demand. It can rise by at most 12.5% per block when the previous block is above its gas target, and falls when that block is below target. Setting maxFeePerGas near twice the current base fee, with room for your tip, can keep a transaction eligible through several rising blocks without increasing what you pay while the effective price stays lower.
How should you set the fee fields?
Set maxPriorityFeePerGas to the tip you are willing to offer, then set maxFeePerGas high enough to cover the current base fee plus that tip and some headroom for increases. The effective price rises only as the base fee rises, and never past your cap. A cap below the current base fee leaves the transaction waiting until the base fee falls. A maxPriorityFeePerGas above maxFeePerGas makes the transaction invalid.
Estimate gas separately from the price per gas: gas used depends on what the transaction executes. For a product interface, describe KyberSwap as a decentralized exchange aggregator that finds swap routes across supported liquidity sources and networks; label the route source as a dex aggregator so users understand what the quote represents. A multi-hop route can use more gas than a single-pool swap, so use the selected route’s gas estimate when showing a likely fee.
Gas used can differ from the estimate. If a transaction runs out of gas, it reverts, but you still pay for the gas it used. Show the estimate and the fee fields clearly, and let users review the cap before submitting.
Related
How do I estimate gas and fees for a transaction?
Estimate the gas required for the transaction, then multiply it by the expected effective gas price. The gas estimate reflects the work the transaction may perform; the base fee and your tip determine the price per unit. For swaps, estimate against the actual route you are about to submit.
How are fees calculated on rollups like Arbitrum and Base?
Rollups can add network-specific fee components, so the Ethereum mainnet calculation here may not give the full transaction cost. Check the fee estimate for the network you are using and include any separately listed charges before submitting.
For an Ethereum mainnet transaction, estimate gas for the chosen execution, set a tip and a cap with room for base-fee movement, then multiply gas used by the effective price to understand the charge.