How the estimate works
A transaction fee is the gas it uses multiplied by the gas price: fee (ETH) = gas units × gas price (gwei) × 10-9. A plain ETH transfer always uses 21,000 gas; contract interactions use more, and the exact amount is shown by your wallet before you sign.
Since EIP-1559 the gas price is the base fee (burned) plus a priority tip. A transaction that fails still pays for the gas it consumed. On rollups, an L1 data fee is added on top of execution gas, so use the L2 fee comparator for those.