The Ultimate Solidity Course
A high quality, in depth Solidity course for experienced developers, free, comprehensive, and trusted by smart contract security experts.
This course is for experienced programmers. If you don’t already know how to code, we suggest picking up Python or JavaScript first then coming back.
If you are new to Solidity, start at the beginning.
However, Solidity developers of all levels can benefit from the resources here in the later sections discuss very advanced topics such as how Tornado Cash works. We also have the only protocol walkthrough of the Compound V3 codebase.
The only paid bootcamp with a free curriculum
Other bootcamps charge hundreds, sometimes thousands of dollars just to see their curriculum. At RareSkills, we believe the entire community benefits when high quality education is freely available. And by free we mean truly free not gated with an email we can monetize later.
The work is truly a public good.
We do hope you will sign up for our bootcamp though! You’ll get time with instructors and a community who have secured billions of dollars in TVL (total value locked).
RareSkills quality
Although this is not a smart contract security course per se, smart contract security researchers regularly refer to the resources here. Our philosophy is that security comes from deeply understanding what you are doing.
Therefore, we don’t create a large list of topics just for the sake of it. We deeply examine non-obvious issues that even experienced Solidity engineers sometimes miss; having taught many through our Solidity Bootcamp we know where the knowledge gaps frequently lie.
Deep understanding should be the expectation for anyone writing code than manages other people’s crypto. As such, our tutorials prioritize generating strong mental models even if it takes more effort to do so.
Finally, we encourage you to compare our tutorials with others on the same subject (and those generated by an AI chatbot).
We are sure you will be impressed at the level of depth, comprehensiveness, and clarity our articles achieve.
No email required! This is for experienced programmers who want to get to the point quickly and immediately practice the information they just gained in a highly optimized topic order. We emphasize the unexpected and unusual aspects of the Solidity language while glossing over things we can reasonably assume to be obvious to a competent developer. Aside from an occasional humorous remark, we’ve made the tutorials as short as possible (but not shorter). Although this is a solidity beginner tutorial, it is intended for experienced coders.
There is a distinction between knowing a language, and knowing a domain. Knowing Python doesn’t make you a data scientist, knowing Javascript doesn’t make you a frontend developer, and knowing Kotlin does not make you an Android developer. Similarly, knowing Solidity does not make you an Ethereum smart contract developer. However, Solidity is a prerequisite for developing smart contracts.
Development Environment
Fixed Size Datatypes: Solidity is a typed language.
Setup your Environment
Arithmetic
If Statements
For Loops
Introduction to arrays and strings
Nested Arrays
Storage Variables
Arrays in Storage
Mappings
Nested Mappings
msg.sender and address(this)
Constructor
Require
ERC20 Tokens
Tuples
Application Binary Interface Encoding (abi encoding)
Calling other Contracts
Token Exchange mini project
Payable Functions
Receive
Block.timestamp and Block.number
Emitting Events
Inheritance
Interfaces
Modifiers
Immutable variables
Constants
Deploying an ERC-721 to OpenSea
Launch and verify an NFT with Foundry
Units of Ethereum: wei, gwei, and ether
Structs
Strings
Unit Testing in Solidity
Your First Solidity Projects
At this point, you now have enough knowledge to build smart contract projects end to end. If you are new to Solidity we strongly recommend you build these projects, not skip them. You can only learn so much by reading tutorials, some knowledge can only be acquired with practice.
Professional Solidity Style Guide
The purpose of this article is not to rehash the official Solidity Style Guide, which you should read.
Common Solidity Beginner Mistakes
Everyone makes mistakes, but some mistakes are more common than others.
Solidity Beginner Projects
You now have enough knowledge to build any of the following projects. Knowledge comes by study, but skill comes with practice.
Token ERCs, Integers in Depth, and Others
If you already know some Solidity but are ready to move to the next level, this is the section to start.
Detecting if an address is a smart contract
This article describes three methods in Solidity for determining if an address is a smart contract:
Solidity Function Selector
The function selector is a 4 byte id that Solidity uses to identify functions under the hood.
ERC-721 design and security issues
ERC721 (or ERC-721) is the most widely used Ethereum standard for nonfungible tokens.
ERC-1155
The ERC-1155 token can hold multiple fungible and non-fungible tokens in a single contract.
ERC-4626
ERC4626 is a tokenized vault standard that uses ERC20 tokens to represent shares of some other asset.
ERC-721 Enumerable
An Enumerable ERC721 is an ERC721 with added functionality that enables a smart contract to list all the NFTs an address owns.
ERC-1363
ERC-1363 enables a smart contract to detect and respond to an incoming transfer of tokens.
Uint256 Max Value
The uint256 max value can be obtained with type(uint256).max
Signed Integers
Solidity signed integers enable using negative numbers in a smart contract. This article documents how they are used at the EVM level.
Solidity Staticcall EIP-214
Staticcall is like a regular Ethereum call except that it reverts if a state change happens.
OpenZeppelin Ownable2Step
The onlyOwner modifier is probably one of the most common patterns in Solidity.
Testing internal functions
To test an internal solidity function, create a child contract that inherits from the contract being tested.
Solidity events
Solidity events are the closest thing to a “print” or “console.log” statement in Ethereum.
Solidity gasleft()
The purpose of this article is to describe the behavior of the solidity gasleft() function and its uses.
Where to find reentrancy attacks
Reentrancy can only happen when your smart contract calls another smart contract via function call or sending ether.
Generate a random number in Solidity
Randomness is tricky on the blockchain because the blockchain is deterministic, but randomness requires non-determinism (otherwise it becomes predictable).
Design Patterns Used Everywhere
Some building blocks and design patterns occur so frequently in DeFi applications that they are best studied directly. Don’t just read these tutorials, practice the problems at the end.
The staking algorithm of MasterChef and Synthetix
The MasterChef and Synthetix staking algorithms distribute a fixed reward pool among stakers according to their time-weighted contributions to a pool.
Fixed Point Arithmetic
A fixed-point number is an integer that stores only the numerator of a fraction — while the denominator is implied.
Flashloans
Flash loans are loans between smart contracts that must be repaid in the same transaction.
Chainlink Price Feeds
Chainlink price oracles are smart contracts with public view functions that return the price of a particular asset denominated in USD.
How DeFi Interest Rates Work
The intuitive way to track lender deposits is to record the amount of USDC they deposited and the time they deposited. Compound V3 does not do this.
The most forked DeFi protocol
Uniswap V2 is the most forked protocol in DeFi and has inspired several more. The Uniswap V2 Book is a line-by-line examination of the protocol.
Architecture
Uniswap is a DeFi app that enables traders to swap one token for another in a trustless manner.
Price Impact of a Swap
This article explains how to determine the price settlement of a trading pair in an Automated Market Maker (AMM).
Swap Function
Uniswap V2’s swap function is cleverly designed, but many devs find its logic counterintuitive the first time they encounter it.
Mint and Burn Functions
The lifecycle of Uniswap V2 is someone mints LP tokens (supplies liquidity, i.e. tokens to the pool) for the first time.
Protocol mintFee
Uniswap V2 was designed to collect 1/6th of the swap fees to the protocol. Since a swap fee is 0.3%, 1/6th of that is 0.05%, so 0.05% of every trade would go to the protocol.
TWAP Oracle
Suppose we have 1 Ether and 2,000 USDC in a pool. This implies that the price of Ether is 2,000 USDC.
UniswapV2Library
The Uniswap V2 Library simplifies some interactions with pair contracts and is used heavily by the Router contracts.
Routers
The Router contracts provide a user-facing smart contract for safely minting and burning LP tokens (adding and removing liquidity)
Building a Uniswap V2 Clone
It’s very educational to rebuild Uniswap v2 from scratch using modern Solidity (or Huff if you really want to do it in hard mode).
The web’s most comprehensive resource on upgradeable smart contracts
ABI Encoding
ABI encoding is the data format used for making function calls to smart contracts. It is also how smart contracts encode data when making calls to other smart contracts.
EVM Storage
How storage variables work under the hood
Low-level call in Solidity
A contract in Solidity can call other contracts via two methods: through the contract interface, which is considered a high-level call, or by using the call method, which is a low-level approach.
Delegatecall
This article explains how delegatecall works in detail. The Ethereum Virtual Machine (EVM) offers four opcodes for making calls between contracts:
ERC-1967
EIP 1967 is a standard for where to store information that proxy contracts need to execute.
ERC-7201
ERC-7201 (formerly EIP-7201) is a standard for grouping storage variables together by a common identifier called a namespace.
Transparent Upgradeable Proxy
The Transparent Upgradeable Proxy is a design pattern for upgrading a proxy while eliminating the possibility of a function selector clash.
Beacon Proxies
EIP 1967 is a standard for where to store information that proxy contracts need to execute.
Clones
EIP-1167, which is also referred to as the minimal proxy contract, is a commonly used solidity pattern for cheaply creating proxy clones.
Metaproxy Clones
The minimal proxy standard allows us to parameterize the creation of the clone, but this requires an extra initialization transaction.
Nodelegatecall
The nodelegatecall modifier prevents delegatecalls from being sent to a contract.
How DAOs coordinate onchain
ERC-20 Snapshots
ERC20 Snapshot solves the problem of double voting.
ERC-20 Votes
ERC20 Votes does not actually handle conducting the poll, it’s still a regular ERC20 token with snapshot and delegated voting abilities.
Solidity Governance
The pattern of governance many DeFi applications follows is heavily inspired by Compound Finance’s implementation.
Explore the codebase of the most influential lending protocol
Compound V2 is the most forked lending protocol, but it is no longer used, so our walkthrough focuses on Compound V3. Nearly every modern lending protocol takes inspiration from Compound, so if you completely understand the codebase, you will easily be able to understand other DeFi lending protocols.
Architechture of Compound V3
Compound is one of the most significant lending protocols in DeFi, having inspired the design of nearly every lending protocol on several blockchains.
Compound V3 Interest Per Second
The Compound V3 protocol measures interest on the scale of seconds. The Compound V3 frontend scales the number up to years for human friendliness.
Principal vs Present Value and Interest Rate Indexes
The intuitive way to track lender deposits is to record the amount of USDC they deposited and the time they deposited.
cUSDC V3 (Comet) as a non-standard Rebasing Token. CometExt.sol
The Compound V3 contract behaves like a rebasing ERC 20 token. A rebasing token is a token which has an algorithmically adjusted supply rather than a fixed one.
Collateral, Liquidations, and Reserves in Compound V3
In this chapter we will examine the following topics about Compound V3: collateral valuation
Compound V3 Rewards
Compound issues rewards in COMP tokens to lenders and borrowers in proportion to their share of the a market’s lending and borrowing.
UniswapV2Library
The Uniswap V2 Library simplifies some interactions with pair contracts and is used heavily by the Router contracts.
Routers
The Router contracts provide a user-facing smart contract for safely minting and burning LP tokens (adding and removing liquidity)
Bulkers in Compound V3
The bulker contracts in Compound V3 are multicall-like contracts for batching several transactions.
The Ultimate guide to improving smart contract efficiency
Our Gas Optimization Course on Udemy
The OG gas optimization course.
Ethereum access list transactions
An Ethereum access list transaction enables saving gas on cross-contract calls by declaring in advance which contract and storage slots will be accessed.
Ultimate List of Solidity Gas Optimization Tricks
Over 80 gas optimization tips and tricks.
What happens behind the Solidity compiler
Our Yul Course on Udemy
Smart contract metadata
When solidity generates the bytecode for the smart contract to be deployed, it appends metadata about the compilation at the end of the bytecode.
Smart contract creation cost
Smart contract creation cost can be anywhere from $10 to $2,000 assuming Ether costs between $1,500 to $2,000.
Smart contract creation code
This article explains what happens at the bytecode level when an Ethereum smart contract is constructed and how the constructor arguments are interpreted.
EIP 150 and the 63/64 rule for gas
EIP-150, or Ethereum Improvement Proposal 150, is a protocol upgrade for the Ethereum blockchain.
Tools to secure your smart contracts
Mistakes in smart contracts can be extremely costly. Therefore, employing as many tools as possible will maximize your chances of success against bugs and hackers.
Invariant Testing in Foundry
In this article, we will discuss invariants and how to perform an invariant test on solidity smart contracts using foundry test suites.
Mutation Testing
Mutation testing is a method to check the quality of the test suite by intentionally introducing bugs into the code and ensuring the tests catch the bug.
For those further on in their Solidity journey
Second Preimage Attack
The second preimage attack in Merkle trees can happen when an intermediate node in a merkle tree is presented as a leaf.
Precompiled smart contracts
Ethereum precompiles behave like smart contracts built into the Ethereum protocol. The nine precompiles live in addresses 0x01 to 0x09.
RSA Signatures in Solidity
Creating a contract that gives certain addresses permissions goes by several names: airdrops, presale, whitelist, allowlist, and so forth.