pub fn compute_base_fee(
parent_base_fee: &BigUint,
parent_gas_used: &BigUint,
parent_target_gas_used: &BigUint,
) -> BigUint
Expand description
Computes the base fee of a block given parent block header data.
§Arguments
parent_base_fee
- The value of the parent block base feeparent_gas_used
- The value of the parent block gas usedparent_target_gas_used
- The value of the parent block target gas used
§Examples
use num_bigint::BigUint;
use eip_utils::eip1559;
let parent_base_fee = BigUint::from(1000000000 as u64);
let parent_gas_used = BigUint::from(10000000 as u64);
let parent_target_gas_used = BigUint::from(5000000 as u64);
let base_fee = eip1559::compute_base_fee(&parent_base_fee, &parent_gas_used, &parent_target_gas_used);
assert_eq!(base_fee, BigUint::from(1125000000 as u64));