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: 0xa1
Introduced: Frontier (EVM genesis)
LOG1 emits a log entry with one indexed topic. This is the most common form for single-parameter event filtering, used extensively in token transfer events and simple state changes.
Specification
Stack Input:
Stack Output:
Gas Cost: 375 + 375 + (8 × data_length) + memory_expansion_cost
Operation:
Behavior
LOG1 pops three 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)
The log entry contains one topic for efficient filtering while supporting arbitrary data.
Topic Values
Topics are stored as full 256-bit values. For dynamic types (strings, arrays, structs), the keccak256 hash is used as the topic:
Memory Expansion
Memory expands in 32-byte words beyond the current allocation, with associated gas costs.
Static Call Protection
LOG1 cannot execute in static call context (EIP-214).
Examples
Basic Topic Logging
Topic with Data
Solidity Transfer Event
Named Event Log
ID-Based Event
Gas Cost
Base Cost: 375 gas
Topic Cost: 375 gas (per topic, 1 for LOG1)
Data Cost: 8 gas per byte
Memory Expansion: Proportional to new memory range
Examples:
- Empty data: 375 + 375 = 750 gas
- 1 byte: 750 + 8 = 758 gas
- 32 bytes: 750 + 256 = 1006 gas
- 64 bytes: 750 + 512 + 3 (memory expansion) = 1265 gas
Edge Cases
Topic Boundary Values
Zero Topic
Large Data
Stack Underflow
Out of Gas
Common Usage
Event Filtering in Contracts
Off-Chain Filtering
State Change Events
Security
Topic Hashing
For dynamic types, ensure consistent hashing:
Static Call Context
LOG1 reverts in view/pure functions:
Topic Value Limits
Topics are stored as full 256-bit values. No truncation or padding:
Implementation
Testing
References