
I will give you an overview of the course and make sure it is right for you.
In this video we learn how to predict the cost of an Ethereum transfer in dollars.
An overview of example transaction fees for various smart contracts part 1
An overview of example transaction fees for various smart contracts part 2
We create our own example smart contract to further develop our intuition about smart contract transaction fees
Learn why gas optimization matters even on ethereum-compatible chains. Analyze gas block limits, transaction sizing, and how adoption and decentralization influence gas costs, with avalanche as an example.
Delve into how opcodes power the Etherium computer by compiling Solidity into stack-based operations, loads, stores, and arithmetic that affect gas costs.
Learn how function selectors in bytecode are four-byte hashes of function names, computed from exact signatures with event types, not variable names (as shown with blue, gray, green, yellow).
Analyze how the data portion of a transaction drives gas costs. Zero bytes incur small increases; non-zero bytes cost 16 gas per byte, four bytes total 64 gas.
Explains the unchecked block in Solidity, why it exists, and how pre-0.8 overflow and underflow could misbehave; shows how 0.8 adds checks and reverts on invalid arithmetic.
Explore unchecked blocks, their gas savings, and the security risks of overflow and underflow; see practical use in OpenZeppelin counters and ERC-20 transfers, with gas analysis via opcodes.
Learn how EIP-1559 changes gas costs by burning the base fee, splitting fees into max priority fee per gas and max fee per gas, and adjusting base fees per block.
Explore how EIP-1559 pricing works, clarifying max base fee, max fee per gas, and max priority fee, and show how base fees are burned and refunds or miner tips arise.
Analyze storage gas costs in Ethereum, including zero to non-zero (20,000 gas plus 2,100 cold storage access fee), non-zero to zero refunds, and the impact of cold storage access fee.
Discover how assigning an unchanged storage value still consumes gas, analyze cold storage vs store costs, and learn a caching-then-conditional update pattern to save gas in Solidity contracts.
Explain how Solidity stores dynamic arrays and the gas costs of array operations, including transaction initiation, storing length, and writing elements, with tricks like cold storage and op-code stepping.
Examine how gas refunds relate to storage changes in ethereum. Reference the yellow paper and IP 3529 adjustments, including the removal of self-destruct refunds and the cap at one fifth of costs.
Explore how Solidity stores structs and strings in storage slots, revealing gas costs, packing behavior, and cold versus warm storage effects.
Discover how variable packing stores two values in a single 32-byte slot, uses offsets and masking to read A and B, and when packing saves gas in Solidity.
Compare less than and less than or equal to in Solidity to understand how opcodes impact gas costs and why choosing cheaper equivalents improves efficiency.
Explore bit shifting in Solidity: left and right shifts represent multiply and divide by two, compare gas costs of shifting versus multiplication, and review overflow risks and benchmark results.
Analyze how precomputing constant expressions in Solidity bytecode can lead to hard-coded results, using pushes and a function selector, while noting where optimization may fail and affect gas costs.
Practice problems for gas optimization
Ever been surprised by the gas costs in a smart contract? The Ethereum Virtual Machine calculates these costs deterministically, but understanding how is a bit obscure unless you want to comb through the dense yellowpaper! This course helps you understand where every last bit of gas is coming from and the gotchas that can make transactions surprisingly expensive.
This course is for solidity developers looking to progress from beginner to advanced intermediate. Knowledge about Solidity, OpenZeppelin, and Remix is assumed. You should know how to deploy and test a smart contract, and ideally, you've created a token on the mainnet before (and experienced how expensive it can be!).
I’m the author of ERC1155D, arguably the most efficient NFT contract created. I’m here to share my learnings with you!
Some of the most enjoyable years of my life was teaching computer science at Columbia University, so I’m happy to relive those years virtually!
Topics covered include:
A deep dive into the solidity compiler
A deep dive into the Ethereum Virtual Machine
How to understand the output from the solidity compiler
How to track down wasteful computation
Understanding gas cost specifications
Techniques for improving gas costs
How memory, transaction data, state changes, and computational cost affect transaction cost
Bad designs to avoid
Where the Yellowpaper is wrong!
Follow me on Twitter: @jeyffre