Smart Contracts¶
Solidity compiles down to exactly the bytecode examined directly in The EVM. This section covers the language from the other direction, going feature by feature from a working "hello world" contract through inheritance, upgradeability, testing, and deployment. Every non-trivial code example in this section has been compiled with a real Solidity compiler (solc 0.8.26) and confirmed to build cleanly, not just written to look plausible.
What you need to know first¶
The EVM. This section explains Solidity constructs largely in terms of what EVM-level mechanism they compile to (a view function's STATICCALL guarantee, DELEGATECALL underlying proxies, storage slots underlying state variables and mappings), so understanding the machine underneath makes the language's specific rules much less arbitrary.
Chapters¶
- Solidity: a minimal contract, compiled, and why the language looks the way it does
- Contract ABI: function selectors computed and cross-checked against a known real value
- Functions: visibility, view/pure, and payable, verified against compiled ABI output
- State Variables: declaration, storage packing, constants, and immutables
- Mappings: why every key already has a value, and what that means for enumeration
- Events and Logs: off-chain-only records, and why they're far cheaper than storage
- Modifiers: the
_;placeholder, and what it actually controls - Errors and Reverts: require, custom errors, and assert compared directly
- Payable Functions: receive/fallback routing, and the three ways to send ether
- Inheritance: virtual/override, and Solidity's C3 linearization rule
- Libraries: stateless, reusable code and the
using forsyntax - Proxy Contracts: a working minimal proxy, and the storage-collision risk it simplifies away
- Upgradeable Contracts: Transparent, UUPS, and Diamond patterns, and who controls the risk
- Testing: Foundry's cheatcodes and fuzz testing, against a real embedded EVM
- Deployment: CREATE vs. CREATE2 addressing, and what contract verification actually proves
Next¶
Continue to Tokens, where this section's mappings, events, and errors patterns combine into the actual ERC-20, ERC-721, and ERC-1155 standards.