The Cairo Programming Language
Foreword
Introduction
1.
Getting Started
1.1.
Installation
1.2.
Hello, World!
2.
Common Programming Concepts
2.1.
Variables and Mutability
2.2.
Data Types
2.3.
Functions
2.4.
Comments
2.5.
Control Flow
3.
Common Collections
3.1.
Arrays
3.2.
Dictionaries
3.3.
Custom Data Structures
4.
Understanding Ownership
4.1.
What is Ownership?
4.2.
References and Snapshots
5.
Using Structs to Structure Related Data
5.1.
Defining and Instantiating Structs
5.2.
An Example Program Using Structs
5.3.
Method Syntax
6.
Enums and Pattern Matching
6.1.
Enums
6.2.
The Match Control Flow Construct
7.
Managing Cairo Projects with Packages, Crates and Modules
7.1.
Packages and Crates
7.2.
Defining Modules to Control Scope
7.3.
Paths for Referring to an Item in the Module Tree
7.4.
Bringing Paths into Scope with the 'use' Keyword
7.5.
Separating Modules into Different Files
8.
Generic Types
8.1.
Generic Functions
8.2.
Traits in Cairo
9.
Testing Cairo Programs
9.1.
How To Write Tests
9.2.
Testing Organization
10.
Error Handling
10.1.
Unrecoverable Errors with panic
10.2.
Recoverable Errors with Result
11.
Advanced Features
11.1.
Operator Overloading
11.2.
Macros
11.3.
Working with Hashes
12.
Starknet Smart Contracts
12.1.
Introduction to smart-contracts
12.2.
A simple contract
12.3.
A deeper dive into contracts
12.3.1.
Contract Storage
12.3.2.
Contract Functions
12.3.3.
Contract Events
12.3.4.
Reducing boilerplate
12.3.5.
Optimizing storage costs
12.4.
Components
12.4.1.
Under the hood
12.4.2.
Component dependencies
12.4.3.
Testing components
12.5.
ABIs and Cross-contract Interactions
12.5.1.
ABIs and Interfaces
12.5.2.
Contract Dispatchers, Library Dispachers and system calls
12.6.
Other examples
12.6.1.
Deploying and Interacting with a Voting contract
12.7.
L1 <> L2 Messaging
12.8.
Security Considerations
13.
Appendix
13.1.
A - Keywords
13.2.
B - Operators and Symbols
13.3.
C - Derivable Traits
13.4.
D - Useful Development Tools
13.5.
E - Common Types & Traits and the Cairo Prelude
13.6.
F - Installing Cairo binaries
Light
Rust
Coal
Navy
Ayu
The Cairo Programming Language
English
Español
Français
简体中文
Testing Cairo Programs