1/5
_Follow along with this video:_ --- ### New Powers Unlocked What was really eye opening to me when I was first learning all this, were the questions that started to come to mind. I'd ask things like ***How necessary is the free memory pointer? Isn't it more gas efficient to omit it?*** ```js PUSH1 0x80 PUSH1 0x40 MSTORE ``` - YES! Arguably it is, and you could write things such that it's not included. ***Doesn't it save gas to not check msg.value on creation?*** ```js CALLVALUE DUP1 ISZERO PUSH1 0x0e JUMPI PUSH0 DUP1 REVERT ``` - Yes! Technically it does. In fact, I challenge you to go add this to our contract and see for yourself, this check will actually be removed from our bytecode! ```js constructor() payable {} ``` >**Note:** Just because it saves gas, doesn't mean it's the best choice. The msg.value check brings some valuable security functionality such as not accidentally locking a bunch of funds on contract creation. Consider your optimizations carefully! There are all sorts of optimizations that will spring to mind the more familiar you become with the deeper workings of the EVM and op codes. In the next lesson we'll introduce `runtime code` in more detail!
A mind-blowing look at your newfound opcode inspecting powers – the lesson covers why you would want to check for `msg.value` in a payable Solidity constructor and how to optimize a simple smart contract's code. You can now create more optimized Solidity code!
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