In this track: Inside the EVM
advanced · 4 MIN READ

LOG opcodes and topics

Logs are explicit EVM effects with memory data and up to four topics.

LET’S PICTURE IT

An instruction can append a labeled record containing selected workspace bytes.

SEE IT FOR YOURSELF
From an emitted Transfer event to a receipt logStep 1 / 4
From an emitted Transfer event to a receipt logToken executionApply coded rulesUpdate relevant balancesEmit Transferfrom · to · valueA structured logA reverted execution portion does not keep its emitted logsTransfer(address,address,uint256)Topic 0: 0xddf252ad…b3efFull digest · 32 bytesEvent topic zero and a function selector use different lengthsTopic 1from addressIndexedTopic 2to addressIndexedDataraw valueNot indexedThis diagram is specifically the common ERC-20 Transfer layoutReceipt logTopics + dataBlock contextApplication viewDecoded fieldsImplementation still mattersThe local event tool does not query or authenticate a deployed token

A token implementation may update balances and emit its standard Transfer event. State and the emitted record are related but distinct.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

Count topics from the opcode

LOG0 through LOG4 specify how many topics accompany the log. Topics are word-sized values, while the data payload comes from a selected memory range.

Connect to event compilation

Solidity event emission compiles into logging behavior. The signature topic convention belongs to the event ABI; the raw LOG opcode does not invent a canonical event name.

Keep the logging address

The log is associated with the current execution address context. Delegate execution can therefore emit a record associated with the proxy rather than the implementation address.

Apply static and rollback rules

Logging is disallowed in static context. Logs from a reverted execution scope do not survive as retained receipt records.

Trace the idea

LOG3 example for common Transfer:
topic 0 = signature digest
topic 1 = from
topic 2 = to
data memory range = encoded raw value

Stack examples list the bottom first and the top last. These small traces omit gas and surrounding dispatch unless stated.

QUICK CHECK · NO PRESSURE

Does LOG1 automatically calculate an event signature?

Your progress stays in this browser.
Keep exploring the original referenceethereum.org ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.