Documentation Index
Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Opcode:0xa4
Introduced: Frontier (EVM genesis)
LOG4 emits a log entry with four indexed topics, the maximum allowed. This enables filtering events with up to four indexed parameters, supporting complex multi-dimensional queries like buyer-seller-token-amount combinations.
Specification
Stack Input:375 + (4 × 375) + (8 × data_length) + memory_expansion_cost
Operation:
Behavior
LOG4 pops six values from the stack:- Offset: Starting position in memory (256-bit value)
- Length: Number of bytes to read from memory (256-bit value)
- Topic0: First indexed parameter (256-bit value)
- Topic1: Second indexed parameter (256-bit value)
- Topic2: Third indexed parameter (256-bit value)
- Topic3: Fourth indexed parameter (256-bit value)
Topic Values
All four topics are preserved as full 256-bit values. For dynamic types, keccak256 hashes are used.Memory Expansion
Memory expands in 32-byte word increments with proportional gas costs.Static Call Protection
LOG4 cannot execute in static call context (EIP-214).Examples
Complex Event with Four Dimensions
Marketplace Event with Full Metadata
Order Book Entry
MultiHop Swap Event
Cross-Chain Bridge Event
Permission Grant Event
Gas Cost
Base Cost: 375 gas Topic Cost: 375 gas per topic = 1500 gas (for 4 topics) Data Cost: 8 gas per byte Memory Expansion: Proportional to new memory range Examples:- Empty data: 375 + 1500 = 1875 gas
- 1 byte: 1875 + 8 = 1883 gas
- 32 bytes: 1875 + 256 = 2131 gas
- 64 bytes: 1875 + 512 + 3 = 2390 gas
- 256 bytes: 1875 + 2048 + 6 = 3929 gas
- 1024 bytes: 1875 + 8192 + 15 = 10082 gas
Edge Cases
All Topics Identical
Mixed Topic Values
Large Data with Maximum Topics
Stack Underflow
Out of Gas
Common Usage
Four-Dimensional Event Filtering
Dimensional Data Warehouse
Maximum Filtering Capability
Security
Topic Visibility and Privacy
All topics are visible off-chain. Maximum topics = maximum visibility:Filtering Logic
Ensure consistent topic interpretation:Static Call Context
LOG4 reverts in view/pure functions:Implementation
- TypeScript

