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:0xa0Introduced: Frontier (EVM genesis)LOG0 emits a log entry with no indexed topics. Only the event data (non-indexed parameters) is logged, making it useful for simple event tracking where filtering by topics is not needed.
Specification
Stack Input:
offset (top)length
Stack Output:
(none)
Gas Cost:375 + (8 × data_length) + memory_expansion_costOperation:
data = memory[offset : offset + length]log_entry = { address: msg.sender, topics: [], data: data }append log_entry to logs
Behavior
LOG0 pops offset and length from the stack, reads data from memory, and appends a log entry:
Offset: Starting position in memory (256-bit value)
Length: Number of bytes to read from memory (256-bit value)
Data: Bytes read from memory, padded with zeros if beyond allocated memory
Topics: Empty array (0 indexed parameters)
Memory Expansion
If the data range extends beyond current memory allocation, memory expands to word boundaries:
event SimpleLog(string message);contract Logger { function log(string memory msg) public { emit SimpleLog(msg); // Compiler generates LOG0 }}// UsageLogger logger = new Logger();logger.log("Hello, world!");// Transaction receipt includes log with empty topics
Non-Indexed Event Parameters
event Transfer(uint256 indexed id, address from, address to, uint256 value);// If only 'id' is indexed, Solidity uses LOG1// But we can emit an event with all non-indexed params using LOG0:event Data(string text, uint256 amount, bytes payload);contract DataLogger { function logData(string memory text, uint256 amount, bytes memory payload) public { emit Data(text, amount, payload); // LOG0 (no indexed params) }}
Gas Cost
Base Cost: 375 gasData Cost: 8 gas per byteMemory Expansion: Proportional to new memory rangeExamples:
const frame = createFrame({ stack: [0n, 0n], gasRemaining: 374n, // Not enough for base cost});const err = handler_0xa0_LOG0(frame);console.log(err); // { type: "OutOfGas" }
Common Usage
Simple State Changes
event Minted(uint256 amount);event Burned(uint256 amount);contract Token { function mint(uint256 amount) public { totalSupply += amount; emit Minted(amount); // LOG0 } function burn(uint256 amount) public { totalSupply -= amount; emit Burned(amount); // LOG0 }}
Unindexed Data Logging
event ConfigUpdated(string newConfig);contract Config { function updateConfig(string memory newConfig) public { config = newConfig; emit ConfigUpdated(newConfig); // LOG0 (newConfig is non-indexed) }}
Status Events
event StatusChanged(string status);contract Service { function shutdown() public { isActive = false; emit StatusChanged("OFFLINE"); // LOG0 }}
Security
Cannot Block On-Chain Filtering
Since LOG0 has no topics, external systems cannot efficiently filter by indexed parameters. This is intentional—use LOG1-LOG4 when filtering capability is needed.
// INEFFICIENT: No topic filteringevent EventWithoutTopics(address user, uint256 amount);// BETTER: Use indexed parametersevent EventWithTopics(address indexed user, uint256 amount);
Static Call Context Restrictions
LOG0 reverts in view/pure functions or during staticcall operations:
function badView() external view { emit SomeEvent(); // Reverts: cannot log in view context}contract Caller { function staticCallBad(address target) public { target.staticcall(abi.encodeCall(Logger.log, ())); // Reverts }}
Memory Boundaries
LOG0 reads memory up to offset + length. Uninitialized memory is zero-filled:
// Be aware of what's written to memoryfunction logUninitialized() public { // If no data written to memory[0:100], emits 100 zero bytes emit Data();}