Skip to main content

Try it Live

Run FeeMarket examples in the interactive playground

FeeMarket Types

TypeScript types for fee market state and calculations.

State

Complete fee market state for a block. Combines EIP-1559 and EIP-4844 state. Properties:
  • gasUsed - Gas used in block (0 to gasLimit)
  • gasLimit - Maximum gas per block
  • baseFee - Base fee per gas (wei), minimum 7
  • excessBlobGas - Accumulated excess blob gas
  • blobGasUsed - Blob gas used in block (0 to 786432)
Example:

Eip1559State

EIP-1559 base fee state subset. Example:

Eip4844State

EIP-4844 blob fee state subset. Example:

TxFeeParams

EIP-1559 transaction fee parameters. Properties:
  • maxFeePerGas - Maximum total fee per gas (wei)
  • maxPriorityFeePerGas - Maximum priority fee/tip (wei)
  • baseFee - Current block base fee (wei)
Constraints:
  • maxFeePerGas >= baseFee (or tx cannot be included)
  • maxPriorityFeePerGas <= maxFeePerGas
Example:

BlobTxFeeParams

EIP-4844 blob transaction fee parameters. Extends TxFeeParams. Additional Properties:
  • maxFeePerBlobGas - Maximum fee per blob gas (wei)
  • blobBaseFee - Current blob base fee (wei)
  • blobCount - Number of blobs (1-6)
Constraints:
  • maxFeePerBlobGas >= blobBaseFee (or tx cannot be included)
  • 1 <= blobCount <= 6
Example:

TxFee

Calculated transaction fee breakdown. Properties:
  • effectiveGasPrice - Actual price per gas paid (wei)
  • priorityFee - Priority fee per gas paid (wei)
  • baseFee - Base fee per gas (wei)
Formula:
  • effectiveGasPrice = min(maxFeePerGas, baseFee + maxPriorityFeePerGas)
  • priorityFee = effectiveGasPrice - baseFee
Example:

BlobTxFee

Calculated blob transaction fee breakdown. Extends TxFee. Additional Properties:
  • blobGasPrice - Actual blob gas price paid (wei per blob gas)
  • totalBlobFee - Total fee for all blobs (wei)
Formula:
  • blobGasPrice = min(maxFeePerBlobGas, blobBaseFee)
  • totalBlobFee = blobGasPrice * BLOB_GAS_PER_BLOB * blobCount
Example:

Type Guards

All types are plain TypeScript interfaces. No runtime type guards provided.

Type Relationships

Branded Types

Types in BrandedState.ts are identical to main types. No phantom branding used.

Usage with Namespace Functions

All functions operate on these plain data types:

Validation

Use validation functions for runtime checks:
See utilities.mdx for validation functions.