Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article covers EIP1559, a proposal addressing volatile transaction fees and inefficient fee auctions by adjusting a base fee for each block and introducing a new mechanism for determining transaction fees.
The following proposal is translated, summarized, and supplemented in this article.
What are gas fees?
For readers unfamiliar with gas fees, here is a brief explanation of their characteristics.

Overview
The proposal introduces a mechanism for dynamically adjusting transaction fees and block sizes on Ethereum.
EIP2718
The proposal introduces a new transaction type using EIP2718.
For more on EIP2718, see the following article.
[EIP2718] Understanding Ethereum's extensible transaction format
0x02 || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, amount, data, access_list, signature_y_parity, signature_r, signature_s])The transaction format is shown above. The following table explains its fields.
Parameters
| Parameter | Description |
|---|---|
0x02 |
Transaction type identifier |
rlp(...) |
Data encoding format (Recursive Length Prefix) |
chain_id |
Chain identifier |
nonce |
Unique transaction counter |
max_priority_fee_per_gas |
Maximum fee paid to prioritize the transaction |
max_fee_per_gas |
Maximum total fee per unit of gas (priority fee + base fee) |
gas_limit |
Maximum gas available for the transaction |
destination |
Destination address |
amount |
Amount to transfer |
data |
Data included in the transaction (typically for contract calls) |
access_list |
List of storage locations to access in advance |
signature_y_parity, signature_r, signature_s |
Transaction signature |
Base fee
The Base Fee rises or falls according to the parent block's (the previous block's) gas usage and gas target (the target amount of gas usage). When gas usage exceeds the target, the base fee increases; when it falls below the target, the base fee decreases.
The Base Fee is burned.
Priority fee
The Max Fee sets the maximum fee that can be paid to execute a transaction. The Max Fee covers the Priority Fee, which rewards miners (validators), and the Base Fee.
Motivation
Problems with the previous fee system
The fee system preceding the proposal had the following problems.
- Fee volatility and mismatch with costs
- The fee auction mechanism is inefficient.
- Transaction fees fluctuate dramatically, so network costs are unpredictable.
- For example, even if fees increase tenfold, the actual resources and energy needed to process a transaction hardly change.
- Waiting time
- A low per-block gas limit delays transaction processing, leaving users waiting.
- Inefficient fee auctions
- Users may pay excessive fees.
- Instability of blockchains without block rewards
- There are concerns about relying solely on transaction fees to compensate miners (validators) if block rewards are eventually removed.
The new proposal
EIP1559 proposes introducing a Base Fee that adjusts according to network congestion.
- Base fee adjustment
- The base fee rises when gas usage exceeds the target and falls when it is below the target.
- Priority fee and maximum fee
- A fee is paid to miners (validators) as a reward for prioritizing a transaction.
- The sender also sets a maximum fee, which is the maximum acceptable total price.
- Burning the base fee
- The base fee is burned and removed from circulation.
This helps counter ETH inflation while removing the incentive for miners to deliberately manipulate the base fee.
The following figures summarize these terms.


The next figure also explains the gas limit.

The following figure illustrates increases and decreases in the base fee.

The following is an example of how EIP1559 gas fees are displayed on Etherscan.

First, the Base fee and Priority Fee are added together and multiplied by Gas Used. The orange box shows gas usage relative to the gas limit. The red boxes show the portions of the resulting amount attributable to the Base fee and Priority Fee. The Base fee is burned, while the Priority Fee is paid to miners (validators) as a tip.
Specification
Refer to the code explanation below as you read this section.
- The
GASPRICE(0x3a) opcode returnseffective_gas_price. - When
FORK_BLOCK_NUMBERis reached, a new EIP2718TransactionTypeis introduced. - The new transaction cost inherits the following calculation from the previous transaction format.
21000 + 16 * non-zero calldata bytes + 4 * zero calldata bytes + 1900 * access list storage key count + 2400 * access list address countParameter descriptions
| Parameter | Description |
|---|---|
| Base cost | 21000 gas |
| Cost per nonzero calldata byte | 16 gas |
| Cost per zero calldata byte | 4 gas |
| Cost per access-list storage key | 1900 gas |
| Cost per access-list address | 2400 gas |
- The EIP2718 transaction data structure is as follows.
TransactionPayloadrlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, amount, data, access_list, signature_y_parity, signature_r, signature_s])Parameter descriptions
| Parameter | Description |
|---|---|
chain_id |
Chain identifier |
nonce |
Unique transaction counter |
max_priority_fee_per_gas |
Maximum priority fee paid to the miner |
max_fee_per_gas |
Maximum total fee per unit of gas |
gas_limit |
Maximum gas available for the transaction |
destination |
Destination address |
amount |
Amount to transfer |
data |
Data included in the transaction (typically for smart contract calls) |
access_list |
List of storage locations to access in advance |
signature_y_parity, signature_r, signature_s |
Transaction signature |
- Transactions use the following secp256k1 signature.
keccak256(0x02 || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, amount, data, access_list]))- The transaction receipt has the following format.
rlp([status, cumulative_transaction_gas_used, logs_bloom, logs])Parameter descriptions
| Parameter | Description |
|---|---|
status |
Status indicating transaction success (1) or failure (0) |
cumulative_transaction_gas_used |
Cumulative gas used by transactions |
logs_bloom |
Bloom filter for logs (a data structure supporting efficient log searches) |
logs |
Log entries generated during transaction execution |
Code
Now consider the actual code.
The complete code is included below, followed by explanations of the most important sections.
Complete code
from typing import Union, Dict, Sequence, List, Tuple, Literal
from dataclasses import dataclass, field
from abc import ABC, abstractmethod
@dataclass
class TransactionLegacy:
signer_nonce: int = 0
gas_price: int = 0
gas_limit: int = 0
destination: int = 0
amount: int = 0
payload: bytes = bytes()
v: int = 0
r: int = 0
s: int = 0
@dataclass
class Transaction2930Payload:
chain_id: int = 0
signer_nonce: int = 0
gas_price: int = 0
gas_limit: int = 0
destination: int = 0
amount: int = 0
payload: bytes = bytes()
access_list: List[Tuple[int, List[int]]] = field(default_factory=list)
signature_y_parity: bool = False
signature_r: int = 0
signature_s: int = 0
@dataclass
class Transaction2930Envelope:
type: Literal[1] = 1
payload: Transaction2930Payload = Transaction2930Payload()
@dataclass
class Transaction1559Payload:
chain_id: int = 0
signer_nonce: int = 0
max_priority_fee_per_gas: int = 0
max_fee_per_gas: int = 0
gas_limit: int = 0
destination: int = 0
amount: int = 0
payload: bytes = bytes()
access_list: List[Tuple[int, List[int]]] = field(default_factory=list)
signature_y_parity: bool = False
signature_r: int = 0
signature_s: int = 0
@dataclass
class Transaction1559Envelope:
type: Literal[2] = 2
payload: Transaction1559Payload = Transaction1559Payload()
Transaction2718 = Union[Transaction1559Envelope, Transaction2930Envelope]
Transaction = Union[TransactionLegacy, Transaction2718]
@dataclass
class NormalizedTransaction:
signer_address: int = 0
signer_nonce: int = 0
max_priority_fee_per_gas: int = 0
max_fee_per_gas: int = 0
gas_limit: int = 0
destination: int = 0
amount: int = 0
payload: bytes = bytes()
access_list: List[Tuple[int, List[int]]] = field(default_factory=list)
@dataclass
class Block:
parent_hash: int = 0
uncle_hashes: Sequence[int] = field(default_factory=list)
author: int = 0
state_root: int = 0
transaction_root: int = 0
transaction_receipt_root: int = 0
logs_bloom: int = 0
difficulty: int = 0
number: int = 0
gas_limit: int = 0 # note the gas_limit is the gas_target * ELASTICITY_MULTIPLIER
gas_used: int = 0
timestamp: int = 0
extra_data: bytes = bytes()
proof_of_work: int = 0
nonce: int = 0
base_fee_per_gas: int = 0
@dataclass
class Account:
address: int = 0
nonce: int = 0
balance: int = 0
storage_root: int = 0
code_hash: int = 0
INITIAL_BASE_FEE = 1000000000
INITIAL_FORK_BLOCK_NUMBER = 10 # TBD
BASE_FEE_MAX_CHANGE_DENOMINATOR = 8
ELASTICITY_MULTIPLIER = 2
class World(ABC):
def validate_block(self, block: Block) -> None:
parent_gas_target = self.parent(block).gas_limit // ELASTICITY_MULTIPLIER
parent_gas_limit = self.parent(block).gas_limit
# on the fork block, don't account for the ELASTICITY_MULTIPLIER to avoid
# unduly halving the gas target.
if INITIAL_FORK_BLOCK_NUMBER == block.number:
parent_gas_target = self.parent(block).gas_limit
parent_gas_limit = self.parent(block).gas_limit * ELASTICITY_MULTIPLIER
parent_base_fee_per_gas = self.parent(block).base_fee_per_gas
parent_gas_used = self.parent(block).gas_used
transactions = self.transactions(block)
# check if the block used too much gas
assert block.gas_used <= block.gas_limit, 'invalid block: too much gas used'
# check if the block changed the gas limit too much
assert block.gas_limit < parent_gas_limit + parent_gas_limit // 1024, 'invalid block: gas limit increased too much'
assert block.gas_limit > parent_gas_limit - parent_gas_limit // 1024, 'invalid block: gas limit decreased too much'
# check if the gas limit is at least the minimum gas limit
assert block.gas_limit >= 5000
# check if the base fee is correct
if INITIAL_FORK_BLOCK_NUMBER == block.number:
expected_base_fee_per_gas = INITIAL_BASE_FEE
elif parent_gas_used == parent_gas_target:
expected_base_fee_per_gas = parent_base_fee_per_gas
elif parent_gas_used > parent_gas_target:
gas_used_delta = parent_gas_used - parent_gas_target
base_fee_per_gas_delta = max(parent_base_fee_per_gas * gas_used_delta // parent_gas_target // BASE_FEE_MAX_CHANGE_DENOMINATOR, 1)
expected_base_fee_per_gas = parent_base_fee_per_gas + base_fee_per_gas_delta
else:
gas_used_delta = parent_gas_target - parent_gas_used
base_fee_per_gas_delta = parent_base_fee_per_gas * gas_used_delta // parent_gas_target // BASE_FEE_MAX_CHANGE_DENOMINATOR
expected_base_fee_per_gas = parent_base_fee_per_gas - base_fee_per_gas_delta
assert expected_base_fee_per_gas == block.base_fee_per_gas, 'invalid block: base fee not correct'
# execute transactions and do gas accounting
cumulative_transaction_gas_used = 0
for unnormalized_transaction in transactions:
# Note: this validates transaction signature and chain ID which must happen before we normalize below since normalized transactions don't include signature or chain ID
signer_address = self.validate_and_recover_signer_address(unnormalized_transaction)
transaction = self.normalize_transaction(unnormalized_transaction, signer_address)
signer = self.account(signer_address)
signer.balance -= transaction.amount
assert signer.balance >= 0, 'invalid transaction: signer does not have enough ETH to cover attached value'
# the signer must be able to afford the transaction
assert signer.balance >= transaction.gas_limit * transaction.max_fee_per_gas
# ensure that the user was willing to at least pay the base fee
assert transaction.max_fee_per_gas >= block.base_fee_per_gas
# Prevent impossibly large numbers
assert transaction.max_fee_per_gas < 2**256
# Prevent impossibly large numbers
assert transaction.max_priority_fee_per_gas < 2**256
# The total must be the larger of the two
assert transaction.max_fee_per_gas >= transaction.max_priority_fee_per_gas
# priority fee is capped because the base fee is filled first
priority_fee_per_gas = min(transaction.max_priority_fee_per_gas, transaction.max_fee_per_gas - block.base_fee_per_gas)
# signer pays both the priority fee and the base fee
effective_gas_price = priority_fee_per_gas + block.base_fee_per_gas
signer.balance -= transaction.gas_limit * effective_gas_price
assert signer.balance >= 0, 'invalid transaction: signer does not have enough ETH to cover gas'
gas_used = self.execute_transaction(transaction, effective_gas_price)
gas_refund = transaction.gas_limit - gas_used
cumulative_transaction_gas_used += gas_used
# signer gets refunded for unused gas
signer.balance += gas_refund * effective_gas_price
# miner only receives the priority fee; note that the base fee is not given to anyone (it is burned)
self.account(block.author).balance += gas_used * priority_fee_per_gas
# check if the block spent too much gas transactions
assert cumulative_transaction_gas_used == block.gas_used, 'invalid block: gas_used does not equal total gas used in all transactions'
# TODO: verify account balances match block's account balances (via state root comparison)
# TODO: validate the rest of the block
def normalize_transaction(self, transaction: Transaction, signer_address: int) -> NormalizedTransaction:
# legacy transactions
if isinstance(transaction, TransactionLegacy):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.signer_nonce,
gas_limit = transaction.gas_limit,
max_priority_fee_per_gas = transaction.gas_price,
max_fee_per_gas = transaction.gas_price,
destination = transaction.destination,
amount = transaction.amount,
payload = transaction.payload,
access_list = [],
)
# 2930 transactions
elif isinstance(transaction, Transaction2930Envelope):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.payload.signer_nonce,
gas_limit = transaction.payload.gas_limit,
max_priority_fee_per_gas = transaction.payload.gas_price,
max_fee_per_gas = transaction.payload.gas_price,
destination = transaction.payload.destination,
amount = transaction.payload.amount,
payload = transaction.payload.payload,
access_list = transaction.payload.access_list,
)
# 1559 transactions
elif isinstance(transaction, Transaction1559Envelope):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.payload.signer_nonce,
gas_limit = transaction.payload.gas_limit,
max_priority_fee_per_gas = transaction.payload.max_priority_fee_per_gas,
max_fee_per_gas = transaction.payload.max_fee_per_gas,
destination = transaction.payload.destination,
amount = transaction.payload.amount,
payload = transaction.payload.payload,
access_list = transaction.payload.access_list,
)
else:
raise Exception('invalid transaction: unexpected number of items')
@abstractmethod
def parent(self, block: Block) -> Block: pass
@abstractmethod
def block_hash(self, block: Block) -> int: pass
@abstractmethod
def transactions(self, block: Block) -> Sequence[Transaction]: pass
# effective_gas_price is the value returned by the GASPRICE (0x3a) opcode
@abstractmethod
def execute_transaction(self, transaction: NormalizedTransaction, effective_gas_price: int) -> int: pass
@abstractmethod
def validate_and_recover_signer_address(self, transaction: Transaction) -> int: pass
@abstractmethod
def account(self, address: int) -> Account: passINITIAL_BASE_FEE = 1000000000
INITIAL_FORK_BLOCK_NUMBER = 10 # TBD
BASE_FEE_MAX_CHANGE_DENOMINATOR = 8
ELASTICITY_MULTIPLIER = 2
def validate_block(self, block: Block) -> None:
parent_gas_target = self.parent(block).gas_limit // ELASTICITY_MULTIPLIER
parent_gas_limit = self.parent(block).gas_limit
# on the fork block, don't account for the ELASTICITY_MULTIPLIER to avoid
# unduly halving the gas target.
if INITIAL_FORK_BLOCK_NUMBER == block.number:
parent_gas_target = self.parent(block).gas_limit
parent_gas_limit = self.parent(block).gas_limit * ELASTICITY_MULTIPLIER
parent_base_fee_per_gas = self.parent(block).base_fee_per_gas
parent_gas_used = self.parent(block).gas_used
transactions = self.transactions(block)
# check if the block used too much gas
assert block.gas_used <= block.gas_limit, 'invalid block: too much gas used'
# check if the block changed the gas limit too much
assert block.gas_limit < parent_gas_limit + parent_gas_limit // 1024, 'invalid block: gas limit increased too much'
assert block.gas_limit > parent_gas_limit - parent_gas_limit // 1024, 'invalid block: gas limit decreased too much'
# check if the gas limit is at least the minimum gas limit
assert block.gas_limit >= 5000
# check if the base fee is correct
if INITIAL_FORK_BLOCK_NUMBER == block.number:
expected_base_fee_per_gas = INITIAL_BASE_FEE
elif parent_gas_used == parent_gas_target:
expected_base_fee_per_gas = parent_base_fee_per_gas
elif parent_gas_used > parent_gas_target:
gas_used_delta = parent_gas_used - parent_gas_target
base_fee_per_gas_delta = max(parent_base_fee_per_gas * gas_used_delta // parent_gas_target // BASE_FEE_MAX_CHANGE_DENOMINATOR, 1)
expected_base_fee_per_gas = parent_base_fee_per_gas + base_fee_per_gas_delta
else:
gas_used_delta = parent_gas_target - parent_gas_used
base_fee_per_gas_delta = parent_base_fee_per_gas * gas_used_delta // parent_gas_target // BASE_FEE_MAX_CHANGE_DENOMINATOR
expected_base_fee_per_gas = parent_base_fee_per_gas - base_fee_per_gas_delta
assert expected_base_fee_per_gas == block.base_fee_per_gas, 'invalid block: base fee not correct'
# execute transactions and do gas accounting
cumulative_transaction_gas_used = 0
for unnormalized_transaction in transactions:
# Note: this validates transaction signature and chain ID which must happen before we normalize below since normalized transactions don't include signature or chain ID
signer_address = self.validate_and_recover_signer_address(unnormalized_transaction)
transaction = self.normalize_transaction(unnormalized_transaction, signer_address)
signer = self.account(signer_address)
signer.balance -= transaction.amount
assert signer.balance >= 0, 'invalid transaction: signer does not have enough ETH to cover attached value'
# the signer must be able to afford the transaction
assert signer.balance >= transaction.gas_limit * transaction.max_fee_per_gas
# ensure that the user was willing to at least pay the base fee
assert transaction.max_fee_per_gas >= block.base_fee_per_gas
# Prevent impossibly large numbers
assert transaction.max_fee_per_gas < 2**256
# Prevent impossibly large numbers
assert transaction.max_priority_fee_per_gas < 2**256
# The total must be the larger of the two
assert transaction.max_fee_per_gas >= transaction.max_priority_fee_per_gas
# priority fee is capped because the base fee is filled first
priority_fee_per_gas = min(transaction.max_priority_fee_per_gas, transaction.max_fee_per_gas - block.base_fee_per_gas)
# signer pays both the priority fee and the base fee
effective_gas_price = priority_fee_per_gas + block.base_fee_per_gas
signer.balance -= transaction.gas_limit * effective_gas_price
assert signer.balance >= 0, 'invalid transaction: signer does not have enough ETH to cover gas'
gas_used = self.execute_transaction(transaction, effective_gas_price)
gas_refund = transaction.gas_limit - gas_used
cumulative_transaction_gas_used += gas_used
# signer gets refunded for unused gas
signer.balance += gas_refund * effective_gas_price
# miner only receives the priority fee; note that the base fee is not given to anyone (it is burned)
self.account(block.author).balance += gas_used * priority_fee_per_gas
# check if the block spent too much gas transactions
assert cumulative_transaction_gas_used == block.gas_used, 'invalid block: gas_used does not equal total gas used in all transactions'
# TODO: verify account balances match block's account balances (via state root comparison)
# TODO: validate the rest of the blockThe code above adjusts gas fees. Each part is explained below in order.
Retrieving the parent block's gas limit and gas target
ELASTICITY_MULTIPLIER = 2
parent_gas_target = self.parent(block).gas_limit // ELASTICITY_MULTIPLIER
parent_gas_limit = self.parent(block).gas_limitThis retrieves the parent block's (the previous block's) gas target and block gas limit, which determine increases and decreases in the base fee. The gas target is the target gas usage, and the block gas limit is the maximum gas that can be included in a block.
Because ELASTICITY_MULTIPLIER is set to 2, the gas target is half the gas limit.
For example, if the block gas limit is 30 million, the gas target is 15 million.
Initial block settings
if INITIAL_FORK_BLOCK_NUMBER == block.number:
parent_gas_target = self.parent(block).gas_limit
parent_gas_limit = self.parent(block).gas_limit * ELASTICITY_MULTIPLIERThis sets the gas target and gas limit for the first block to which EIP1559 applies. Unlike the preceding case, the gas limit is set to twice the gas target.
Retrieving the parent block's base fee and gas usage
parent_base_fee_per_gas = self.parent(block).base_fee_per_gas
parent_gas_used = self.parent(block).gas_used
transactions = self.transactions(block)This retrieves the parent block's base fee, gas usage, and transaction data.
Gas usage (gas_used) is the gas consumed when transferring ETH or executing contract operations. Here, block gas usage is the total gas used by all transactions in the block.
Checking gas usage
# check if the block used too much gas
assert block.gas_used <= block.gas_limit, 'invalid block: too much gas used'An error is raised if block gas usage exceeds the new block's gas limit.
Checking the gas limit
# check if the block changed the gas limit too much
assert block.gas_limit < parent_gas_limit + parent_gas_limit // 1024, 'invalid block: gas limit increased too much'
assert block.gas_limit > parent_gas_limit - parent_gas_limit // 1024, 'invalid block: gas limit decreased too much'This checks that the new block's gas limit does not increase or decrease by as much as 1/1024 of the parent block's gas limit.
This prevents sudden changes in the gas limit.
Checking the minimum gas limit
# check if the gas limit is at least the minimum gas limit
assert block.gas_limit >= 5000The new block must have a gas limit of at least 5000.
Expected base fee
INITIAL_BASE_FEE = 1000000000
BASE_FEE_MAX_CHANGE_DENOMINATOR = 8
# check if the base fee is correct
if INITIAL_FORK_BLOCK_NUMBER == block.number:
expected_base_fee_per_gas = INITIAL_BASE_FEE
elif parent_gas_used == parent_gas_target:
expected_base_fee_per_gas = parent_base_fee_per_gas
elif parent_gas_used > parent_gas_target:
gas_used_delta = parent_gas_used - parent_gas_target
base_fee_per_gas_delta = max(parent_base_fee_per_gas * gas_used_delta // parent_gas_target // BASE_FEE_MAX_CHANGE_DENOMINATOR, 1)
expected_base_fee_per_gas = parent_base_fee_per_gas + base_fee_per_gas_delta
else:
gas_used_delta = parent_gas_target - parent_gas_used
base_fee_per_gas_delta = parent_base_fee_per_gas * gas_used_delta // parent_gas_target // BASE_FEE_MAX_CHANGE_DENOMINATOR
expected_base_fee_per_gas = parent_base_fee_per_gas - base_fee_per_gas_delta
assert expected_base_fee_per_gas == block.base_fee_per_gas, 'invalid block: base fee not correct'This section checks the base fee.
INITIAL_FORK_BLOCK_NUMBER == block.number- For the first block after EIP1559 is introduced, the base fee is set to the fixed value
INITIAL_BASE_FEE(1000000000).
- For the first block after EIP1559 is introduced, the base fee is set to the fixed value
parent_gas_used == parent_gas_target- If the parent block's gas usage equals its gas target, the base fee remains the same as in the parent block.
parent_gas_used > parent_gas_target- If the parent block's gas usage exceeds the gas target set for that block, the following calculation determines the expected increase in the new block's base fee.
- Multiply the parent block's base fee (
parent_base_fee_per_gas) by the difference between its gas usage and gas target (gas_used_delta). - Divide the product by the parent block's gas target (
parent_gas_target), divide the result again byBASE_FEE_MAX_CHANGE_DENOMINATOR(8), and take the larger of that result and1. - Finally, add the calculated amount to the parent block's base fee to obtain the new block's base fee.
The division by BASE_FEE_MAX_CHANGE_DENOMINATOR limits the change in the base fee.
Worked example
-
parent_base_fee_per_gas100 gwei
-
gas_used_delta2,000,000 gas
-
parent_gas_target10,000,000 gas
-
BASE_FEE_MAX_CHANGE_DENOMINATOR8
-
``parent_base_fee_per_gas * gas_used_delta`
100 gwei * 2,000,000 gas = 200,000,000 gwei// parent_gas_target
200,000,000 gwei // 10,000,000 gas = 20 gwei// BASE_FEE_MAX_CHANGE_DENOMINATOR
20 gwei // 8 = 2.5 gwei(整数除算では2 gwei)- `max(..., 1)
max(2 gwei, 1 gwei) = 2 gwei-
else- Conversely, if the parent block's gas usage is below its gas target, calculate the decrease in the new block's base fee.
- The calculation is the same as above, except for the final operation: subtract the calculated amount from the parent block's base fee.
-
assert expected_base_fee_per_gas == block.base_fee_per_gas- Finally, check whether the expected base fee calculated above equals the base fee set in the new block.
The following figure illustrates how the base fee works.

Checking transactions
cumulative_transaction_gas_used = 0
for unnormalized_transaction in transactions:The code checks each transaction in the block individually.
signer_address = self.validate_and_recover_signer_address(unnormalized_transaction)This verifies the transaction signature and chain ID and retrieves the signer's address.
transaction = self.normalize_transaction(unnormalized_transaction, signer_address)The transaction is normalized, removing information such as the signature and chain ID that is no longer needed.
Detailed processing
def normalize_transaction(self, transaction: Transaction, signer_address: int) -> NormalizedTransaction:
# legacy transactions
if isinstance(transaction, TransactionLegacy):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.signer_nonce,
gas_limit = transaction.gas_limit,
max_priority_fee_per_gas = transaction.gas_price,
max_fee_per_gas = transaction.gas_price,
destination = transaction.destination,
amount = transaction.amount,
payload = transaction.payload,
access_list = [],
)
# 2930 transactions
elif isinstance(transaction, Transaction2930Envelope):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.payload.signer_nonce,
gas_limit = transaction.payload.gas_limit,
max_priority_fee_per_gas = transaction.payload.gas_price,
max_fee_per_gas = transaction.payload.gas_price,
destination = transaction.payload.destination,
amount = transaction.payload.amount,
payload = transaction.payload.payload,
access_list = transaction.payload.access_list,
)
# 1559 transactions
elif isinstance(transaction, Transaction1559Envelope):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.payload.signer_nonce,
gas_limit = transaction.payload.gas_limit,
max_priority_fee_per_gas = transaction.payload.max_priority_fee_per_gas,
max_fee_per_gas = transaction.payload.max_fee_per_gas,
destination = transaction.payload.destination,
amount = transaction.payload.amount,
payload = transaction.payload.payload,
access_list = transaction.payload.access_list,
)
else:
raise Exception('invalid transaction: unexpected number of items')The function above is executed.
def normalize_transaction(self, transaction: Transaction, signer_address: int) -> NormalizedTransaction:It defines two arguments and a return value.
Parameters
transaction- Transaction object.
- Processing differs according to the transaction type.
signer_address- Address of the transaction signer.
Return value
NormalizedTransaction- Normalized transaction object.
if isinstance(transaction, TransactionLegacy):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.signer_nonce,
gas_limit = transaction.gas_limit,
max_priority_fee_per_gas = transaction.gas_price,
max_fee_per_gas = transaction.gas_price,
destination = transaction.destination,
amount = transaction.amount,
payload = transaction.payload,
access_list = [],
)If the transaction is a legacy transaction (a type preceding EIP1559), its contents are adjusted as follows to support the new gas pricing mechanism.
max_priority_fee_per_gasandmax_fee_per_gasboth use the samegas_price.- Legacy transactions have no
access_list, so an empty list is assigned.
elif isinstance(transaction, Transaction2930Envelope):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.payload.signer_nonce,
gas_limit = transaction.payload.gas_limit,
max_priority_fee_per_gas = transaction.payload.gas_price,
max_fee_per_gas = transaction.payload.gas_price,
destination = transaction.payload.destination,
amount = transaction.payload.amount,
payload = transaction.payload.payload,
access_list = transaction.payload.access_list,
)Similarly, a transaction of the Transaction2930Envelope type is processed.
max_priority_fee_per_gasandmax_fee_per_gasboth use the samegas_price.- The
access_listis taken from the EIP2930 transaction payload.
elif isinstance(transaction, Transaction1559Envelope):
return NormalizedTransaction(
signer_address = signer_address,
signer_nonce = transaction.payload.signer_nonce,
gas_limit = transaction.payload.gas_limit,
max_priority_fee_per_gas = transaction.payload.max_priority_fee_per_gas,
max_fee_per_gas = transaction.payload.max_fee_per_gas,
destination = transaction.payload.destination,
amount = transaction.payload.amount,
payload = transaction.payload.payload,
access_list = transaction.payload.access_list,
)Finally, transactions of the EIP1559 type are processed.
max_priority_fee_per_gasandmax_fee_per_gasare taken from separate fields.- The
access_listis taken from the EIP1559 transaction payload.
else:
raise Exception('invalid transaction: unexpected number of items')An error is raised for transactions that do not match any of the three types.
signer = self.account(signer_address)The signer's account information is retrieved.
signer.balance -= transaction.amount
assert signer.balance >= 0, 'invalid transaction: signer does not have enough ETH to cover attached value'Any amount transferred by the transaction is deducted from the signer's balance, and the balance is checked.
assert signer.balance >= transaction.gas_limit * transaction.max_fee_per_gasThis checks whether the signer's balance can cover the transaction gas limit multiplied by the maximum fee.
assert transaction.max_fee_per_gas >= block.base_fee_per_gasThis checks that the transaction's maximum fee is at least the block's base fee.
The transaction's maximum fee is the highest fee that the signer is willing to pay. A transaction whose maximum fee is below the base fee cannot be included in the block.
assert transaction.max_fee_per_gas < 2**256
assert transaction.max_priority_fee_per_gas < 2**256
assert transaction.max_fee_per_gas >= transaction.max_priority_fee_per_gasThis checks that transaction fees are not excessively large. It also checks that the priority fee, which is paid to miners or validators as a reward, does not exceed the transaction's maximum fee.
priority_fee_per_gas = min(transaction.max_priority_fee_per_gas, transaction.max_fee_per_gas - block.base_fee_per_gas)
effective_gas_price = priority_fee_per_gas + block.base_fee_per_gasThe priority fee is calculated, followed by the effective gas price (base fee + priority fee).
signer.balance -= transaction.gas_limit * effective_gas_price
assert signer.balance >= 0, 'invalid transaction: signer does not have enough ETH to cover gas'The transaction's gas limit multiplied by the gas price is deducted from the signer's balance to check whether the signer can afford it.
gas_used = self.execute_transaction(transaction, effective_gas_price)The transaction is executed, and the actual gas used is retrieved.
gas_refund = transaction.gas_limit - gas_used
cumulative_transaction_gas_used += gas_used
signer.balance += gas_refund * effective_gas_priceUnused gas is refunded to the signer.
self.account(block.author).balance += gas_used * priority_fee_per_gasThe priority fee for the gas used is paid to the miner (validator).
# check if the block spent too much gas transactions
assert cumulative_transaction_gas_used == block.gas_used, 'invalid block: gas_used does not equal total gas used in all transactions'This checks whether total gas used by all transactions in the block equals the gas usage value specified in the new block.
Compatibility
Legacy transactions can still be included and processed in blocks, but they are processed according to the new gas pricing algorithm.
Changes to the block hash
Because the data structure passed to keccak256 to calculate the block hash has changed, applications using the block hash for purposes such as block validation must support the new data structure.
Changes to GASPRICE
Previously, GASPRICE represented both the ETH paid by the transaction signer per unit of gas and the ETH received by the miner.
With EIP1559, it returns only the ETH paid per unit of gas.
Security
Increased block size and complexity
EIP1559 increases the maximum block size. If miners take too long to process blocks, they may mine empty blocks instead. Miners therefore need to provision their hardware to process blocks of the maximum size.
Transaction ordering
With less scope for competition based on the priority fee, transaction ordering becomes dependent on the client's internal implementation. Miners are encouraged to prioritize higher-fee transactions and sort transactions with the same priority fee by their time of arrival.
Possibility of miners producing empty blocks
Miners might mine empty blocks until the base fee becomes very low and then resume mining transactions. The proposal considers this unproblematic as long as mining is decentralized.
Changes in ETH supply due to burning
Burning the base fee changes the ETH supply. Depending on the amount generated through mining rewards, ETH supply may be inflationary or deflationary. This cannot be predicted precisely, so the ETH supply can no longer be controlled in the same way.
References
Vitalik Buterin (@vbuterin), Eric Conner (@econoar), Rick Dudley (@AFDudley), Matthew Slipper (@mslipper), Ian Norden (@i-norden), Abdelhamid Bakhta (@abdelhamidbakhta), "EIP-1559: Fee market change for ETH 1.0 chain," Ethereum Improvement Proposals, no. 1559, April 2019. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1559.
Conclusion
This article covered EIP1559's gas fee mechanism. I hope it was useful.

