Skip to main content

Try it Live

Run Hardfork examples in the interactive playground

    EIP-4844 Features

    Active Since: Cancun (March 13, 2024)

    Blob Transactions (Type 3)

    Transaction Format:
    • Type 3 transactions (blob-carrying)
    • Up to 6 blobs per transaction (~125KB each, total ~750KB)
    • Blobs stored in consensus layer (not execution layer)
    • Blobs pruned after ~18 days (4096 epochs)
    Blob Properties:
    • Size: 4096 field elements × 32 bytes = 131,072 bytes (~128KB)
    • Encoding: BLS12-381 field elements
    • KZG commitments for data availability proofs

    New Opcodes

    BLOBHASH (0x49):
    • Pushes versioned hash of blob at given index
    • Input: blob index (0-5)
    • Returns: 32-byte versioned hash
    BLOBBASEFEE (0x4A):
    • Pushes current blob gas base fee
    • Returns: blob base fee per gas

    Blob Gas Market

    Separate Fee Market:
    • Blob gas separate from execution gas
    • Target: 3 blobs per block (393,216 blob gas)
    • Maximum: 6 blobs per block (786,432 blob gas)
    • Base fee adjustment: EIP-1559-style mechanism
    Pricing:
    • Independent blob base fee (starts at 1 wei)
    • Exponential adjustment based on blob usage
    • Much cheaper than calldata (~10-100x reduction)

    Usage Patterns

    L2 Data Availability

    Select cheapest L2 data posting method:
    import { Hardfork } from 'tevm'
    
    function selectL2DataMethod(fork: BrandedHardfork): string {
      if (fork.hasEIP4844()) {
        return "blobs"  // ~$0.01-0.10 per blob
      }
    
      return "calldata"  // ~$1-10 per equivalent data
    }
    
    // L2 rollups save 10-100x on data costs with blobs
    

    Transaction Type Selection

    Choose appropriate transaction format:
    import { Hardfork } from 'tevm'
    
    function buildL2BatchSubmission(
      fork: BrandedHardfork,
      data: Uint8Array
    ) {
      if (fork.hasEIP4844() && data.length > 50_000) {
        return {
          type: 3,  // Blob transaction
          blobs: chunkIntoBlobs(data),
          maxFeePerBlobGas: estimateBlobFee()
        }
      }
    
      return {
        type: 2,  // EIP-1559
        data: data  // Expensive calldata
      }
    }
    

    Gas Estimation

    Calculate costs for blob vs calldata:
    import { Hardfork } from 'tevm'
    
    function estimateL2PostingCost(
      fork: BrandedHardfork,
      dataSize: number,
      blobBaseFee: bigint,
      gasPrice: bigint
    ): bigint {
      if (fork.hasEIP4844()) {
        // Blob cost
        const blobsNeeded = Math.ceil(dataSize / 131_072)
        const blobGas = BigInt(blobsNeeded) * 131_072n
        return blobGas * blobBaseFee
      }
    
      // Calldata cost (16 gas per non-zero byte)
      const calldataGas = BigInt(dataSize) * 16n
      return calldataGas * gasPrice
    }
    

    Opcode Availability

    Check blob-related opcodes:
    import { Hardfork } from 'tevm'
    
    function getBlobOpcodes(fork: BrandedHardfork) {
      if (fork.hasEIP4844()) {
        return {
          BLOBHASH: 0x49,
          BLOBBASEFEE: 0x4A
        }
      }
    
      return null  // Not available
    }
    

    Smart Contract Integration

    Access blob hashes in smart contracts:
    import { Hardfork } from 'tevm'
    
    function generateBlobHashLoader(fork: BrandedHardfork): Uint8Array {
      if (!fork.hasEIP4844()) {
        throw new Error("Blob transactions require Cancun or later")
      }
    
      // Generate bytecode: PUSH1 0, BLOBHASH
      return new Uint8Array([0x60, 0x00, 0x49])
    }
    

    Network Configuration

    Validate blob transaction support:
    import { Hardfork, CANCUN } from 'tevm'
    
    function validateBlobSupport(config: NetworkConfig) {
      const fork = Hardfork(config.hardfork)
    
      if (!fork.hasEIP4844()) {
        throw new Error(
          `Network ${config.name} does not support blob transactions. ` +
          `Requires Cancun or later, got ${Hardfork.toString(fork)}`
        )
      }
    }
    

    EIP References

    Primary: Related: Cryptography:
    • KZG polynomial commitments (BLS12-381 curve)
    • Point evaluation precompile at 0x0A

    Impact

    For L2 Rollups:
    • 10-100x cost reduction for data availability
    • Enables higher throughput at lower cost
    • Standard data availability layer for Ethereum L2s
    For Users:
    • Lower L2 transaction fees
    • No direct impact on L1 transactions (separate fee market)
    For Developers:
    • Must handle Type 3 transactions
    • Blob data only available for ~18 days (temporary storage)
    • KZG commitments for data availability proofs
    • New opcodes: BLOBHASH, BLOBBASEFEE
    For Validators:
    • Increased block size (~125KB per blob, max 6 blobs)
    • Separate blob gas fee market
    • Blobs pruned from consensus layer after ~18 days

    See Also

    • hasEIP1153 - Check transient storage availability (Cancun)
    • hasEIP1559 - Check EIP-1559 base fee availability (London)
    • isAtLeast - General version comparison