Cairo course

Cairo Level 6: Starknet Contracts

Starknet Contracts is level 6 of 14 of the LoWisa Cairo course. It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

Updated 2026-11-30

Contract Structure

  • Contract modules. A Starknet contract is a module with the #[starknet::contract] attribute: state plus entry points.
  • Storage struct. The Storage struct declares persistent state: every field a storage variable.
  • Constructor. The constructor runs once at deployment: initial owners and parameters written into storage.

Storage

  • Reads and writes. State reads with self.field.read() and writes with write: access explicit, costs visible.
  • Storage mappings. A storage Map keys values by address or id: balances and ownership tables.
  • Storage packing. Storage slots cost: packing small fields and lean layouts are money, as on every chain.

External Functions

  • external and view. #[external] functions mutate state; view functions promise reads only: the ABI surface.
  • Contract state parameter. Entry points receive self: ContractState threading storage access through signatures.
  • Inputs validated. Every external input is untrusted: validated before any storage write, always.

Before and after this level

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 6: Starknet Contracts cover?

Contract Structure, Storage, External Functions: 3 lessons and 9 ideas.

What should I know before this level?

The level before it, Level 5: Modules & Packages, which covers Modules, Scarb, Package Organisation.

Learn Cairo on your phone

The first level is free. LoWisa is on Google Play and the App Store.