Summary
This EIP proposes a new RUNCODE
opcode that enables execution of arbitrary bytecode from memory within the same execution context. This complements DELEGATECALL
by providing an alternative for scenarios where dynamic code doesn’t need to be permanently stored on-chain, offering significant gas savings.
Key Benefits
-
Alternative to DELEGATECALL: Provides option for temporary/generated code that doesn’t require permanent on-chain storage
-
Gas Optimization: Saves up to 2,600 gas per execution by eliminating cold address access costs
-
Reduced Blockchain Bloat: Avoids deploying temporary bytecode as contracts, reducing state growth
-
Deployment Savings: Eliminates need to deploy ephemeral code as contracts (~32,000+ gas savings per deployment)
-
Context Preservation: Maintains identical execution context as
DELEGATECALL
while operating from memory
Use Cases
-
Runtime code generation and execution without permanent deployment
-
One-time complex calculations that don’t justify permanent contract storage
-
Temporary computational libraries that change frequently
-
Meta-programming patterns where bytecode is generated dynamically
-
Mathematical computation libraries that generate optimized bytecode on-demand
Discussion Goals
Prior to opening a pull request to the EIPs repository, this proposal seeks community feedback on:
- Real-world use cases where
RUNCODE
provides significant value - Any overlooked security implications compared to
DELEGATECALL
- Whether any opcode restrictions should be applied within
RUNCODE
- The appropriateness of the proposed 100 gas base cost
Comments, concerns, and alternative perspectives are highly encouraged.
— Alan Bojorquez (@camax)