Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Advanced Solidity: Understanding and Optimizing Gas Costs
Rating: 4.9 out of 5(632 ratings)
3,207 students

Advanced Solidity: Understanding and Optimizing Gas Costs

Mastering the Ethereum Virtual Machine and the Solidity Compiler
Created byJeffrey Scholz
Last updated 10/2022
English

What you'll learn

  • Learn how the Ethereum Virtual Machine sets the gas price
  • Learn how to improve the gas price of existing code
  • Learn how to debug execution costs for smart contracts
  • Learn what designs to avoid that lead to high execution costs

Course content

5 sections46 lectures2h 48m total length
  • Introduction2:37

    I will give you an overview of the course and make sure it is right for you.

  • Lecture 2: Calculating The Cost of an Ethereum Transfer3:04

    In this video we learn how to predict the cost of an Ethereum transfer in dollars.

  • Example Smart Contract Interactions Part 13:59

    An overview of example transaction fees for various smart contracts part 1

  • Example Smart Contract Interactions Part 21:09
  • Example Smart Contract Interactions Part 23:37

    An overview of example transaction fees for various smart contracts part 2

  • Heavy and Light Functions1:52

    We create our own example smart contract to further develop our intuition about smart contract transaction fees

  • Block Limit4:40
  • Gas Efficient Chains2:38
  • Prerequisite: Storage Slots2:31
  • What are Opcodes5:06
  • Opcode Gas Cost2:54
  • Opcode Debugging Gas Cost3:00
  • Function Selectors1:47
  • Cost of Doing Nothing: Op Codes6:08
  • Cost of Doing Nothing: Sum of Op Codes2:29
  • Cost of Doing Nothing: Transaction Data2:21
  • Cost of Doing Nothing: Memory Costs5:37
  • Non-payable Functions3:13
  • Unchecked Arithmetic Part 13:00
  • Unchecked Arithmetic Part 24:47
  • Gas Limit and More on 21,000 Gas5:01
  • EIP 1559 Part 16:15
  • EIP 1559 Part 25:00
  • Solidity Optimizer6:18

Requirements

  • Basic understanding of solidity
  • Ideally, created an ERC-20 or ERC-721 token before

Description

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

Who this course is for:

  • Smart contract developers looking to make their smart contracts more gas efficient