Solidity theorytheory 0/50 · 0%
Low level · medium

31. call, delegatecall and staticcall

Three ways to reach other code.

`call` runs the target's code in the target's context. `delegatecall` runs the target's code in *your* storage, `msg.sender` and `msg.value` — the basis of proxies and libraries. `staticcall` forbids state changes.

(bool ok, bytes memory out) = impl.delegatecall(msg.data);

Delegatecall to an untrusted address is fatal: it can rewrite every storage slot you own.

Check your understanding

  1. 1. Whose storage does `delegatecall` use?

  2. 2. What does `staticcall` forbid?

  3. 3. Why is delegatecall to unknown code dangerous?