Encyclopedia Ethereum · Entry 116
Delegatecall: whose code runs, and whose storage changes?
In this article
At a glance
Key facts
| Fact | Detail | Source |
|---|---|---|
| Code | The target supplies code, not a separate storage context. | [1] |
| State | Storage writes affect the calling context. | [1] |
| Caller information | msg.sender and msg.value are preserved rather than replaced as in an ordinary nested call. | [1] |
One instruction changes which storage is edited
Suppose a proxy delegates to logic that writes an owner field. That write changes the proxy’s storage slot under the implementation’s layout assumptions. It does not simply edit an independent owner field at the implementation address.
If layouts disagree, a write intended for one variable can corrupt another. This is a code-and-state compatibility issue, not merely a display problem.
Choosing code can amount to choosing policy
An authority that can select a new delegated implementation may change transfer rules, permissions and asset-handling behavior within the design’s constraints.
The security boundary includes the implementation-selection mechanism. Reviewing only the currently selected logic leaves future authorized changes out of the analysis.
Read delegated calls differently from ordinary calls
A trace labels DELEGATECALL separately because its target identifies the code source. It should not automatically be read as an ETH payment to that target.
To understand the outcome, follow storage context, call type and any subsequent external calls. The presence of a target address alone is insufficient.
Direct answers
Questions people ask
Is delegatecall always a vulnerability?
No. It is an intentional EVM mechanism used by libraries and proxies. Its safety depends on trusted code selection, compatible storage and correctly enforced authority.
Inspect the evidence
The answer and key facts have stable claim links. These records retain the scope and qualification when reused.
DELEGATECALL executes code from another address in the calling contract’s context. Storage, address and balance remain those of the caller, while msg.sender and msg.value are preserved from that context. This enables proxies and libraries, but delegated code can act on the caller’s state with substantial authority.
Scope: Ethereum · data through 2026-10-02. Verification: verified · 2026-10-02T18:12:41.505Z.
Link to this claimCode: The target supplies code, not a separate storage context.
Scope: Ethereum · data through 2026-10-02. Verification: verified · 2026-10-02T18:12:41.505Z.
Link to this claimState: Storage writes affect the calling context.
Scope: Ethereum · data through 2026-10-02. Verification: verified · 2026-10-02T18:12:41.505Z.
Link to this claimCaller information: msg.sender and msg.value are preserved rather than replaced as in an ordinary nested call.
Scope: Ethereum · data through 2026-10-02. Verification: verified · 2026-10-02T18:12:41.505Z.
Link to this claimRevision history
- — First publication after primary-source research and independent automated verification.
Source register
Sources and references
Retrieval dates and locators are recorded individually.- Solidity: Delegatecall and LibrariesSolidity contributors
Execution uses another contract’s code in the caller’s context and storage.
Locator: Delegatecall and Libraries; Storage, Memory and the Stack; Logs; Message Calls · Version / scope: Solidity 0.8.30 documentation · Retrieved: 2026-10-02T17:03:42.822ZOpen source - Layout of State Variables in Storage and Transient StorageSolidity contributors
Persistent storage slots, packing and mappings.
Locator: Layout of State Variables; Mappings and Dynamic Arrays · Version / scope: Solidity 0.8.30 documentation · Retrieved: 2026-10-02T17:03:42.820ZOpen source - Proxy contractsOpenZeppelin
Proxy implementation slots, delegated execution and upgrade authority.
Locator: TransparentUpgradeableProxy; UUPSUpgradeable; ERC1967Proxy · Version / scope: OpenZeppelin Contracts 5.x · Retrieved: 2026-10-02T17:03:43.024ZOpen source - Geth built-in tracersGo Ethereum
Nested EVM call traces and the distinction between tracing and top-level transactions.
Locator: callTracer; prestateTracer · Retrieved: 2026-10-02T17:25:58.908ZOpen source
Research and drafting use AI assistance. A separate automated review checks claims against primary sources; no external expert or named human review is implied. Publication, substantive editing, source retrieval and verification are recorded separately. This version was independently checked by an automated reviewer on 2 October 2026.
Editorial method and correctionsDegrees of Satoshi editorial project. “Delegatecall: whose code runs, and whose storage changes?.” Published 2026-10-02; updated 2026-10-02. https://degreesofsatoshi.com/encyclopedia/delegatecall-explained/