B003: Maximal Gas Optimizations

Transaction Fees

Compilation Optimizer

Costly Notions

Looks simple, right?
  • Contains three mapping lookups
  • Reads a full storage slot three times
  • Upcasts a bytes8 three times

Mapping Lookups

Redundant Lookups Eliminated

Storage Access

Variable Tight Packing
Struct Stored in Memory

Type Upcasting

Optimized Data Types

Comparison

  • Contains three mapping lookups — Contains a single mapping lookup
  • Reads a full storage slot three times — Reads a full storage slot once
  • Upcasts a bytes8 three times — Contains no upcasting

Conclusion

--

--

--

A Solidity security auditor keen to share his knowledge.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The scary part of blockchain in insurance

Metagame Arena, The Creators of the Prometheus NFT Game, to List on BitMart Exchange

Avalaunch to be the First Avalanche-Native Launchpad Creating Equitable Opportunities for Avalanche

Introduction  DEFIHERO is a public project managed by an international team, which makes up an…

NFTs and Questionable Tokenomics

Monthly Digest — January 2021

Toward a Political Sociology of Blockchain — an Introduction

DeFi Explained: Origin Protocol

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alex Papageorgiou

Alex Papageorgiou

A Solidity security auditor keen to share his knowledge.

More from Medium

The MechArcade Reveal Mechanism

Blockchain Development for Dummies (The Dummy Being Me)

FFS OG NFT drop — verify your wallet-id submission

Web3 Reference Architecture

Web3 Reference Architecture