Solidity is the statically-typed, curly-braces programming language used to write smart contracts that run on the Ethereum Virtual Machine (EVM) and every EVM-compatible chain (Layer 2s, sidechains, and beyond). It exists to let developers encode financial and organizational logic β tokens, exchanges, lending markets, governance β as code that executes exactly as written, with no server operator able to change it after deployment. The mental model that makes everything else click: a deployed contract's storage is permanent and metered by gas, so every design decision here is really two decisions at once β what the code should do, and what it will cost someone to make it do that. Keep that tension in mind while reading the tables below, from how state lives in 32-byte storage slots through the gas-optimization tricks and design patterns experienced Solidity engineers reach for by default.
What This Cheat Sheet Covers
This topic spans 14 focused tables and 133 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Contract Structure and State Variables
A Solidity file is a small, strict skeleton β license, pragma, then one or more contracts holding persistent state β and getting this skeleton right is the first thing any reviewer or auditor checks.
| Element | Example | Description |
|---|---|---|
// SPDX-License-Identifier: MIT | Required first line of every source file; omitting it only produces a compiler warning, not an error. | |
pragma solidity ^0.8.30; | Declares the compiler version(s) the file is written for; fix the exact version for a deployed app, leave it floating ( ^) only for a reusable library. | |
contract Token { } | Similar to a class in OOP languages; bundles persistent state and the functions that read or modify it. | |
uint256 public totalSupply; | Declared at contract level; its value is permanently written to on-chain storage, unlike a local function variable. |