Solidity REPL
Contracts & calls

Receive and fallback functions

Compare an empty call with unmatched calldata on the same contract.

Solidity 0.8.36REPL mode

Why use this example

Use this pattern to test contract composition, external calls, events, and return values inside one reproducible run. The entry isolates receive and fallback functions so its input, result, and state changes stay easy to compare.

Solidity to run

contract Receiver {
  uint256 public emptyCalls;
  uint256 public dataCalls;
  receive() external payable { emptyCalls++; }
  fallback() external payable { dataCalls++; }
}

Receiver receiver = new Receiver()
(bool receiveOk,) = address(receiver).call("")
(bool fallbackOk,) = address(receiver).call(hex"deadbeef")
receiveOk
fallbackOk
receiver.emptyCalls()
receiver.dataCalls()

Official Solidity reference

Compare this focused investigation with the complete language definition in the Solidity documentation.

Receive and fallback functions

What to expect

The empty call reaches receive, the calldata call reaches fallback, and each counter increments once.

Continue the investigation

Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.

Read about calls and logs Reproducible investigation