Values and Types
- felt252. Cairo’s native scalar is the felt252: a field element, the number type proofs are built from.
- Integer types. Bounded integers: u8 through u256: add checked arithmetic on top of felts.
- let and mut. let binds immutably; mut opts into mutation: visible at the binding, Rust-style.
Functions
- fn. A fn declares typed parameters and returns: pub marking what a module exposes.
- Expressions. Blocks and ifs are expressions: the last expression is the value, no return ceremony needed.
- Panics. Unrecoverable failure panics: halting execution; recoverable failure prefers typed results.
Control Flow
- if and match. Cairo branches with if and match: matching enums exhaustively, checked by the compiler.
- Loops. loop and while iterate: with gas metering bounding what a transaction may run.
- Recursion. Cairo favours recursion for iteration: the functional shape provers reason about well.
Before and after this level
- Before: Start Here: Programs That Can Prove Their Execution: Cairo and STARK Proofs, Cairo and Starknet.
- Next: Level 2: Data Structures: Structs and Enums, Pattern Matching, Collections.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Cairo Level 1: Cairo Foundations cover?
Values and Types, Functions, Control Flow: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Start Here: Programs That Can Prove Their Execution, which covers Cairo and STARK Proofs, Cairo and Starknet.