Coin Brief ENDE

EIP-8298 drops the runtime-only restriction on SETCODEFROM and lets initcode use it

A commit to the EIPs repository revises EIP-8298, which proposes SETCODEFROM, an EVM instruction that sets the current account's code hash to the code hash of a source account that already has deployed code, with the new code visible to later execution. The change in this commit is small in text and not in effect: the abstract previously described a "runtime-only" instruction, and that qualifier is gone. The commit title makes the intent explicit — allow SETCODEFROM in initcode, and require an existing deployed code account as the source.

The EIP's stated motivation is code reuse and deployment economics: deploying many contracts that carry identical runtime code is expensive, and this gives a way to point at code that already exists on chain instead of paying to write it again. The proposal lists EIP-3529, 3607, 6780, 7702, 8037 and 8038 among its requirements.

EIP-8298 drops the runtime-only restriction on SETCODEFROM and lets initcode use it
EIP-8298 drops the runtime-only restriction on SETCODEFROM and lets initcode use it — Coin Brief

What it means

Allowing the instruction during initcode is the difference between an optimisation and a deployment pattern. Restricted to runtime, SETCODEFROM is a way for an already-deployed account to change what it runs. Available in initcode, it becomes the mechanism by which a contract acquires its code in the first place, which is what makes the factory pattern cheap rather than merely cheaper.

It also moves the question of what a deployed contract's code is. The requirement that the source be an account with existing deployed code is the safety rail here, and it is doing real work: it means the code being adopted has itself been through deployment, rather than being assembled at the point of use. Anyone building tooling that reasons about bytecode — verifiers, indexers, anything that caches by code hash — should read the final wording closely, because an account's code becoming a reference to another account's code changes what those caches are keyed on.

Written by Victoria Shinder.