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
Opcodes: 0xa0 (LOG0) to 0xa4 (LOG4)`
Introduced: Frontier (EVM genesis)
The LOG family of instructions emits event logs that external systems (off-chain indexers, monitoring services) can capture and process. Each instruction encodes a fixed number of topics (indexed parameters) and flexible data, enabling efficient event filtering without on-chain computation.
Instruction Set
| Opcode | Name | Topics | Stack Items |
|---|
| 0xa0 | LOG0 | 0 | 2 (offset, length) |
| 0xa1 | LOG1 | 1 | 3 (offset, length, topic0) |
| 0xa2 | LOG2 | 2 | 4 (offset, length, topic0, topic1) |
| 0xa3 | LOG3 | 3 | 5 (offset, length, topic0, topic1, topic2) |
| 0xa4 | LOG4 | 4 | 6 (offset, length, topic0, topic1, topic2, topic3) |
Gas Cost
All LOG instructions cost:
Examples:
- LOG0 with empty data: 375 gas
- LOG1 with 32 bytes: 375 + 375 + 256 = 1006 gas
- LOG4 with 64 bytes: 375 + (4 × 375) + 512 = 2387 gas
Memory expansion costs apply when reading data beyond current allocation.
Key Constraints
EIP-214 (Static Call Protection):
LOG instructions cannot execute in static call context. Attempting to log during a STATICCALL reverts with StaticCallViolation.
Data Limit:
Data size is limited by available gas and memory. No hard cap exists, but practical limits depend on transaction gas budget.
Common Usage
Event Indexing
Event Filtering
Off-chain services use topics for fast filtering without parsing all event data:
Multiple Events
A transaction can emit multiple logs, which are returned in order:
Implementation Notes
Topic Encoding
Topics are 256-bit values. For dynamic types (strings, arrays), the keccak256 hash is used:
Data vs Topics
- Topics (0-4): Indexed parameters, optimized for efficient filtering
- Data: Non-indexed parameters, stored but not indexed
References