The Ethereum Virtual Machine (EVM)
The Ethereum Virtual Machine (EVM) is the core component of the Ethereum network. This component allows the execution of smart contracts written in Solidity. After writing the contract, it is compiled into bytecode and deployed to the EVM.
Solidity Assembly refers to a low-level programming language that allows developers to write code at a level closer to the EVM itself. It provides a more granular control over the execution of smart contracts, allowing for optimizations and customization that may not be achievable through higher-level Solidity code alone. The language used for inline assembly in Solidity is known as Yul.
Yul is an intermediate language that compiles to EVM bytecode. It is designed to be a low-level language that gives developers a high degree of control over the execution of their smart contracts. It can be used in stand-alone mode and for inline assembly inside Solidity.
Yul is designed to be a low-level stack-based language, providing developers with the ability to write more optimized and efficient code. It serves as the bridge between the higher-level Solidity code and the low-level EVM bytecode.
In this repository you will find a set of examples that I have written in order to master Yul programming and smart contract optimization. Also, you will find exercises from courses and other articles.
Folders
- Udemy-Course-Yul: These are my exercises from the course Advanced Solidity: Yul and Assembly, developed by Jeffrey Scholz in Udemy.
Suggested Videos
-
Ethereum Under the Hood: Algorithms And Data Structures by Marek Kirejczyk
-
EVM From Solidity to Bytecode, Memory & Storage by Peter Robinson
-
Demystifying EVM Opcodes by Gilbert G at ETH Global (2022).
-
Demystifying Ethereum Assembly by Joshua Riley at Devcon Bogota (2022)
-
EVM Opcodes for Gas Optimizations by Patrick Collins at Chainlink Hackaton (2022)
-
Alex Roan: Hitchhiker’s Guide to the EVM by Alex Roan at SmartCon Developer (2021)
Additional Resources
-
EVM Codes - An EVM Opcodes Interactive Reference: Interactive Website & EVM playground. A very useful tool to practice and observe how opcodes work.
-
Andreas Antonopoulos - The Ethereum Virtual Machine: In this ebook, chapter 13 covers the fundamentals of how the EVM works and shows the EVM interaction with the protocol layer.
-
Femboy Capital - A Playdate with the EVM: This blogpost deep dive into the EVM, explaining how stack machines work before showing how to write assembly code.
-
Solidity Tutorial All About Assembly: A blogpost that explains in detail about EVM assembly, opcodes & using it in solidity.
-
Openzeppelin - Deconstructing a Solidity Contract: A series of blog posts to describe in detail how the solidity code is interpreted and executed by the EVM.
-
Diving Into the Ethereum Virtual Machine: In this series of articles the author deep dive into the Ethereum Virtual Machine and Opcodes.
-
Noxx - EVM Deep Dives: A series of blog posts that review in detail specific parts of the EVM taking you from solidity code to the EVM opcodes
-
Fvictorio - EVM Puzzle: These repositories are a collection of interactive EVM puzzles on GitHub.
-
Official Solidity Docs: Official Solidity Docs for how storage, memory & calldata are handled in a solidity contract