Introduction


This piece is a surgical analysis and explanation of an underrated presentation called The Dark Arts of Yul, about esoteric gas-optimization techniques in Yul, given by our very own @optimizoor on @SolidityFridays:

https://youtu.be/ew3pfnb2_V8

Screenshot 2023-06-04 at 10.10.54 AM.png

This article assumes that its readers have a basic familiarity with Ethereum, its smart-contract programming language, Solidity, and its intermediate assembly-like language, Yul.

Table of Contents


  1. Quick Brush-ups
  2. Scratch Space++
  3. Bit Safety/Security
  4. Inlining
  5. General Tips
  6. SumDemo
    1. SumDemo0
    2. SumDemo1
    3. SumDemo2
    4. SumDemo3
    5. SumDemo4
    6. SumDemo5
    7. SumDemo6
    8. SumDemo7
  7. LookupDemo
    1. LookupDemo0
    2. LookupDemo1-2
  8. MaskingDemo
    1. MaskingDemo0
    2. MaskingDemo1
    3. MaskingDemo2
    4. MaskingDemo3
  9. ECDSA
  10. LibClone