Skip to main content
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.

Overview

Opcode: 0xa3 Introduced: Frontier (EVM genesis) LOG3 emits a log entry with three indexed topics. This enables filtering complex events with multiple dimensional parameters, such as marketplace events involving buyer, seller, and item.

Specification

Stack Input:
Stack Output:
Gas Cost: 375 + (3 × 375) + (8 × data_length) + memory_expansion_cost Operation:

Behavior

LOG3 pops five values from the stack:
  1. Offset: Starting position in memory (256-bit value)
  2. Length: Number of bytes to read from memory (256-bit value)
  3. Topic0: First indexed parameter (256-bit value)
  4. Topic1: Second indexed parameter (256-bit value)
  5. Topic2: Third indexed parameter (256-bit value)
Topics enable efficient three-dimensional filtering for complex event relationships.

Topic Values

All three topics are preserved as full 256-bit values. For dynamic types, keccak256 hashes apply.

Memory Expansion

Memory expands in 32-byte word increments with proportional gas costs.

Static Call Protection

LOG3 cannot execute in static call context (EIP-214).

Examples

Marketplace Event

Marketplace Transaction with Price

NFT Transfer Event

Approval with Token Event

Order Placed Event

Gas Cost

Base Cost: 375 gas Topic Cost: 375 gas per topic = 1125 gas (for 3 topics) Data Cost: 8 gas per byte Memory Expansion: Proportional to new memory range Examples:
  • Empty data: 375 + 1125 = 1500 gas
  • 1 byte: 1500 + 8 = 1508 gas
  • 32 bytes: 1500 + 256 = 1756 gas
  • 64 bytes: 1500 + 512 + 3 = 2015 gas
  • 256 bytes: 1500 + 2048 + 6 = 3554 gas

Edge Cases

All Topics Identical

Mixed Topic Values

Large Data with Topics

Stack Underflow

Out of Gas

Common Usage

Multi-Dimensional Filtering

Off-chain filtering:

Complex State Transitions

Authorization Events

Security

Topic Visibility

All topics are visible off-chain. Do not include sensitive data:

Filtering Semantics

Ensure consistent topic ordering and filtering:

Static Call Context

LOG3 reverts in view/pure functions:

Implementation

Testing

References