Skip to main content
Try out the RareSkills ZK AI Tutor!
Solidity Tutorial

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.

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.

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.

1.

Detecting if an address is a smart contract

This article describes three methods in Solidity for determining if an address is a smart contract:

2.

Solidity Function Selector

The function selector is a 4 byte id that Solidity uses to identify functions under the hood.

3.

ERC-721 design and security issues

ERC721 (or ERC-721) is the most widely used Ethereum standard for nonfungible tokens.

4.

ERC-1155

The ERC-1155 token can hold multiple fungible and non-fungible tokens in a single contract.

5.

ERC-4626

ERC4626 is a tokenized vault standard that uses ERC20 tokens to represent shares of some other asset.

6.

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.

7.

ERC-1363

ERC-1363 enables a smart contract to detect and respond to an incoming transfer of tokens.

8.

Uint256 Max Value

The uint256 max value can be obtained with type(uint256).max

9.

Signed Integers

Solidity signed integers enable using negative numbers in a smart contract. This article documents how they are used at the EVM level.

10.

Solidity Staticcall EIP-214

Staticcall is like a regular Ethereum call except that it reverts if a state change happens.

11.

OpenZeppelin Ownable2Step

The onlyOwner modifier is probably one of the most common patterns in Solidity.

12.

Testing internal functions

To test an internal solidity function, create a child contract that inherits from the contract being tested.

13.

Solidity events

Solidity events are the closest thing to a “print” or “console.log” statement in Ethereum.

14.

Solidity gasleft()

The purpose of this article is to describe the behavior of the solidity gasleft() function and its uses.

15.

Where to find reentrancy attacks

Reentrancy can only happen when your smart contract calls another smart contract via function call or sending ether.

16.

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).

The web’s most comprehensive resource on upgradeable smart contracts
1.

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.

2.

EVM Storage

How storage variables work under the hood

3.

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.

4.

Delegatecall

This article explains how delegatecall works in detail. The Ethereum Virtual Machine (EVM) offers four opcodes for making calls between contracts:

5.

ERC-1967

EIP 1967 is a standard for where to store information that proxy contracts need to execute.

6.

ERC-7201

ERC-7201 (formerly EIP-7201) is a standard for grouping storage variables together by a common identifier called a namespace.

7.

Transparent Upgradeable Proxy

The Transparent Upgradeable Proxy is a design pattern for upgrading a proxy while eliminating the possibility of a function selector clash.

8.

Beacon Proxies

EIP 1967 is a standard for where to store information that proxy contracts need to execute.

9.

Clones

EIP-1167, which is also referred to as the minimal proxy contract, is a commonly used solidity pattern for cheaply creating proxy clones.

10.

Metaproxy Clones

The minimal proxy standard allows us to parameterize the creation of the clone, but this requires an extra initialization transaction.

11.

Nodelegatecall

The nodelegatecall modifier prevents delegatecalls from being sent to a contract.

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.