Solidity REPL
Contracts & calls

Delegatecall storage context

Run another contract’s code while writing to the caller’s storage.

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 delegatecall storage context so its input, result, and state changes stay easy to compare.

Solidity to run

contract Logic {
  uint256 public value;
  function set(uint256 next) external { value = next; }
}
contract Proxy {
  uint256 public value;
  function run(address logic, uint256 next) external returns (bool) {
    (bool ok,) = logic.delegatecall(abi.encodeWithSignature("set(uint256)", next));
    return ok;
  }
}

Logic logic = new Logic()
Proxy proxy = new Proxy()
proxy.run(address(logic), 42)
proxy.value()
logic.value()

Official Solidity reference

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

Delegatecall

What to expect

The delegatecall succeeds and writes 42 into Proxy storage while the Logic contract’s own value remains 0.

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