In this track: Write and read Solidity
advanced · 4 MIN READ

Function parameters and return values

Inputs and outputs have typed ABI shapes with different call-data framing.

LET’S PICTURE IT

A form has fields to fill in and a response form with its own fields.

SEE IT FOR YOURSELF
Build a transfer call from typed fieldsStep 1 / 4
Build a transfer call from typed fieldstransfer(address,uint256)Recipient: 0x0000…0001Raw amount: 100Diagram labels abbreviate addresses; the lab shows full bytes4-byte selectora9059cbbEach box is one byte; this prefix is not a 32-byte wordWord 0 · recipient address12 zero bytes20 address bytes000…0001Left padding preserves the lower-order address valueSelector4 bytesa9059cbbAddress32 bytesword 0Amount32 bytesword 1 → 0x644 + 32 + 32 = 68 bytesThe integer does not contain token decimals or market price

The standard transfer interface takes an address and a raw integer amount. This diagram uses address one and amount one hundred.

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

Inputs belong to a chosen function

A standard external function request begins with a selector followed by its encoded arguments. Canonical parameter types are part of the selector’s signature.

Outputs omit that selector prefix

Ordinary ABI return data encodes the declared results without prepending the function’s four-byte selector. Decode it using the known output schema rather than treating it as another function call.

Names are documentation, types are representation

Return names can improve readability. They do not make the raw bytes self-describing or guarantee a particular implementation is honest. Multiple results can have a tuple-like encoding.

Check direction before decoding

Know whether bytes are calldata, return data, event data or revert data. The surrounding interface determines framing. A decoder choosing the wrong direction can produce nonsense or reject valid bytes.

Read the example

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract LearningExample {
    function split(uint256 x)
        external pure returns (uint256 half, uint256 remainder)
    {
        return (x / 2, x % 2);
    }
}

The two returned integers are ABI-encoded without a function selector prefix.

QUICK CHECK · NO PRESSURE

Do ordinary ABI return values prepend the called function selector?

Your progress stays in this browser.
Keep exploring the original referenceSolidity documentation ↗

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