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

42. Inline assembly and Yul

When to drop to the metal.

Yul gives direct access to EVM opcodes inside an `assembly` block. It is useful for reading arbitrary storage slots, cheap memory manipulation and proxy fallbacks — and it disables the compiler's safety checks.

assembly {
    let v := sload(slot)
    mstore(0x00, v)
    return(0x00, 0x20)
}

Use it sparingly, comment every line, and keep a high-level reference implementation to test against.

Check your understanding

  1. 1. What does `sload` do?

  2. 2. What safety do you lose in assembly?

  3. 3. A good use of assembly is: