In this track: Build, test and reason
advanced · 4 MIN READ

Test event emission

Verify emitter, topics, data and rollback behavior.

LET’S PICTURE IT

An action record should name the right office and contain the expected fields.

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.

Use a known declaration

PracticeCounter emits Increased(address indexed caller,uint256 value). Its signature topic uses the canonical event types, while caller is an indexed field.

Check the emitted address

The local receipt should attribute the record to the deployed counter instance. A matching topic from another contract is not the same assertion.

Decode the exact fields

After the first successful increment, caller should be the owner and value should be one. Do not infer the value only from a UI message.

Test rejected execution

An unauthorized call must not leave a surviving Increased log. A trace can show attempted operations differently from retained receipt logs.

Define the test

increment as owner
find log emitted by the counter
assert Increased(owner, 1)
rejected call → no retained Increased log

Test plans are framework-neutral unless labeled as complete Solidity or JavaScript. Use a local test environment and no real funds.

QUICK CHECK · NO PRESSURE

Should an event test check the emitting address?

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.