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

Return data and copying

A child call leaves a result buffer separate from its success flag.

LET’S PICTURE IT

A completed request has both an outcome indicator and an attached response envelope.

SEE IT FOR YOURSELF
Use temporary memory in one execution frameStep 1 / 4
Use temporary memory in one execution framePointer wordmemory address 0x40value: 0x80Working areabegins at 0x80not a storage slotCompiler memory conventions differ from persistent storage layoutValue 42hex: 0x2aleft-padded in a wordMSTOREoffset 0x80bytes 0x80–0x9fA retained manual allocation must also maintain the memory pointerMLOADoffset 0x80read 32 bytesStack result42same stored wordMLOAD and SLOAD access different data locationsRETURN rangeoffset 0x80size 32 bytesOutput bytesencoded integer 42caller interprets schemaEach message-call frame has its own memory working space

This frame uses temporary byte-addressed memory. Solidity normally keeps a free memory pointer at address 0x40, initially pointing to 0x80.

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

Check the call outcome

A low-level call exposes whether the child succeeded and can provide returned bytes. The byte sequence alone is not a reliable substitute for checking success.

Inspect the return-data size

RETURNDATASIZE reports the size of the current return-data buffer. It does not guarantee that the bytes match the expected output schema.

Copy only a valid range

RETURNDATACOPY requires the requested source range to fit the buffer. Unlike calldata loading, an out-of-range return-data copy does not simply create padded success data.

Bound resource use

Copying attacker-influenced output can consume memory and gas. An application should decide how much output it actually needs and handle unusually large results.

Trace the idea

CALL → success flag + return-data buffer
RETURNDATASIZE → byte count
RETURNDATACOPY → validated range into memory

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

QUICK CHECK · NO PRESSURE

Is a failed call’s payload always successful function output?

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.