1/5
_Follow along with this video:_ --- Wooo! This is very exciting. You've just written your first smart contract in Huff, and in so doing, you learnt a tonne about the deeper machinations of the EVM and how Op Codes work! Let's recap some of the more important things we've covered in this section. ### Function Dispatching We learnt that, no matter the language you're writing your smart contract in(Solidity, Huff, Vyper..) they all start with a `Function Dispatcher` A `function dispatcher` is a section of code which is responsible for checking the `function selectors` of passed `call data` and routing the call to the appropriate logic associate with the `function selector`. ### Op Codes In addition to working with `function dispatchers`, we learnt how to manage storage slots via Huff's `FREE_STORAGE_POINTER()`! We also learnt a variety of op codes and they're uses. We learnt: - PUSH# - Adds items to the stack with # being representative of the number of bytes being pushed. - CALLDATALOAD - loads received `call data` into the stack for reference. - SSTORE - saves values to storage - SLOAD - loads into the stack, values from storage - MSTORE - add values to memory - JUMPI - routes code executing to a particular section of logic based on a conditional. - STOP - ends execution successfully - REVERT - ends execution with error, unsuccessfully ### Wrap Up This is heavy stuff, but you're doing great. If you're feeling a little overwhelmed - now's a great time to take a break. If things aren't quite clicking, I encourage you to come back and tinker with things. Make changes to our Huff contract, experiment with how the different op codes interact with each other. Additionally, the [Huff Documentation](docs.huff.sh) does a great job helping to understand the EVM and I encourage you to give it a read as supplemental learnings. In the next lessons we're going to be diving into how to write Foundry tests which are compatible with Huff, allowing us to do all of our Huff debugging in Foundry. Let's go!
A comprehensive guide to writing a HuFF Smart Contract. The lesson covers the fundamentals of HuFF, including writing your first HuFF contract, understanding OpCodes, and how to debug contracts using foundry.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on January 17, 2025
Solidity Developer
Assembly and Formal VerificationDuration: 30min
Duration: 4h 38min
Duration: 3h 57min
Duration: 1h 56min
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on January 17, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar