UNPKG

@nomicfoundation/ethereumjs-tx

Version:
10 lines (8 loc) 376 B
import type { EIP1559CompatibleTx } from '../types.js' export function getUpfrontCost(tx: EIP1559CompatibleTx, baseFee: bigint): bigint { const prio = tx.maxPriorityFeePerGas const maxBase = tx.maxFeePerGas - baseFee const inclusionFeePerGas = prio < maxBase ? prio : maxBase const gasPrice = inclusionFeePerGas + baseFee return tx.gasLimit * gasPrice + tx.value }