push.org/bootcamp
Advanced Solidity:
Design, Optimization
And
Security
Session 3
push.org/bootcamp
Coming up…
3:30 PM | Solidity 101: Within the heart of Good Smart Contracts… |
3:45 PM | Building and Testing a SC using Foundry |
4:00 PM | Brief glance EVM and Opcodes |
4:20 PM | Mental Models for Optimizing your Smart Contracts |
4:50 PM | Break |
5: 00 PM | Smart Contract Security & Bonus Tips for Smart Contract Devs |
push.org/bootcamp
Stage 1:
Within the heart of a Good Smart Contract
push.org/bootcamp
Within the heart of Good Smart Contracts….
What does “Good Smart Contract” mean?
push.org/bootcamp
Basics of a Good Smart Contract Codebase
What does a professional Solidity Code look like?
Step Zero: Be Specific
Smart Contracts are Immutable
Therefore, Be very specific.
Write SRS, before SOLIDITY
push.org/bootcamp
Solidity Contract Header
What does a professional Solidity Code look like?
3. Imports
push.org/bootcamp
Order of Layout
What does a professional Solidity Code look like?
push.org/bootcamp
State Variables
What does a professional Solidity Code look like?
push.org/bootcamp
Functions in Solidity
What does a Solidity Function look like?
push.org/bootcamp
Functions in Solidity
Anatomy of a Solidity Function
push.org/bootcamp
Order of Functions
How to order different types of function in a Smart Contract?
push.org/bootcamp
Notes on Functions
Additional Notes on solidity functions
push.org/bootcamp
Data Types in Solidity
Value Types
Reference Types
push.org/bootcamp
Address Types in Solidity
Basic Details
Technical Details
A (sort-of) unique data type that you might not have seen
push.org/bootcamp
Variable Types
State Variables
push.org/bootcamp
Variable Types
Local Variables
push.org/bootcamp
Variable Types
Global Variables
push.org/bootcamp
Data Locations
What are events in Solidity?
push.org/bootcamp
Data Locations
What are events in Solidity?
2. Memory
push.org/bootcamp
Data Locations
What are events in Solidity?
3. Calldata
push.org/bootcamp
Time to build a Smart Contract
push.org/bootcamp
Let’s Build a Contract
Time to build
What to build?
push.org/bootcamp
Let’s Build a Contract
Time to build
What to build?
Questions:
Step Zero: Write a SRS Doc first
push.org/bootcamp
Building a SRS Doc
Time to build
push.org/bootcamp
Events in Solidity
What are events in Solidity?
push.org/bootcamp
Error Handling
How are errors handled in solidity?
Error handling indicates exceptions that lead to States completely being reverted.
Solidity provides 3 main ways to handling errors:
push.org/bootcamp
Error Handling
How are errors handled in solidity?
require statements
require(msg.sender == owner, "Only owner can call this function");
Mainly Used for:
push.org/bootcamp
Error Handling
How are errors handled in solidity?
Custom Errors statements
push.org/bootcamp
Foundry Tests
Imperative to write tests in foundry
push.org/bootcamp
Foundry Tests
Verbosity of foundry forge test
Adjusting details of test output using verbosity params
push.org/bootcamp
Foundry Tests
Helper functions for foundry tests
Assertions
Pranks ( adjusting CALLER)
Time ( adjusting timestamp)
push.org/bootcamp
Stage 2:
EVM Opcodes &
Optimization of Gas
push.org/bootcamp
EVM and Opcodes
Tricks to optimize gas in solidity
push.org/bootcamp
Journey of a Smart Contract
push.org/bootcamp
Bytecodes
push.org/bootcamp
Opcodes
push.org/bootcamp
Optimizing Gas
Basic Rule of thumb when saving gas
push.org/bootcamp
Optimizing Gas
Tricks to optimize gas in solidity
Mapping vs Array
push.org/bootcamp
Optimizing Gas
Tricks to optimize gas in solidity
Arrangement of IF-ELSE Conditional Blocks
(Short-Circuit Evaluation)
push.org/bootcamp
Optimizing Gas
Tricks to optimize gas in solidity
Avoiding Storage Reads
push.org/bootcamp
Optimizing Gas
Tricks to optimize gas in solidity
Avoiding Storage Reads in Loops
push.org/bootcamp
Stage 3:
Smart Contract Security & Audits
push.org/bootcamp
Limitations of Smart Contracts
push.org/bootcamp
Introduction to Smart Contract Security
Why is it important ?
push.org/bootcamp
Possible Solutions
Following Best Security Practices while Development of Smart Contracts
Performing extensive Smart Contract Security Audits
push.org/bootcamp
Best Security Practices
push.org/bootcamp
Brief glance at Smart Contract Audits
Smart contract audits usually have 5 Imperative Steps
push.org/bootcamp
Bonus Section:
Recommendations, Advices and Tips
push.org/bootcamp
With Great Power, Comes Great Responsibility
push.org/bootcamp
Tips for Solidity Developers
Work on the HARD Problem
push.org/bootcamp
Raising the Bar - As a SC Dev
Imperative ERC Standards
ERC’s Upgradeable Proxy Standards
Crucial DEFI Terms & Projects
Important Projects
push.org/bootcamp
Raising the Bar - As a SC Security Researcher
What to Learn - Where to learn
Play, Participate & Learn
Security Tools
push.org/bootcamp
push.org/bootcamp