Practical overview
When it fits
Use Cairo when your development task involves writing provable programs, compiling or running Cairo files, or following the repository's Starknet contract compilation workflow.
Who it is for
- Developers creating provable programs for general computation.
- Developers compiling or running Cairo source files.
- Starknet developers compiling contracts to Sierra ContractClass and CASM outputs.
Documented uses
- Write programs intended for provable general computation.
- Compile a single Cairo file to Sierra and then CASM.
- Run a Cairo file through the documented runner.
- Compile Starknet contracts from a project path or single-file input, with contract selection when a project defines multiple contracts.
Requirements & limits
The compiler repository is public and open source under the Apache-2.0 license. Building from source requires Rust, with the repository instructions specifying the stable toolchain.
- The documented source-build path requires Rust and uses Cargo commands from the repository.
- Cairo-to-Sierra-to-CASM compilation and direct file execution are separate documented workflows.
- Starknet contract compilation supports project-path and single-file inputs; projects containing multiple contracts can specify a contract path.
- The repository describes the language as Turing-complete and intended for provable general computation.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Compile and run a Cairo file
Use the documented compiler to produce Sierra and CASM outputs, or run a Cairo file directly.
Before you start
- Install Rust and set up the stable toolchain.
- A Cairo source file at the path used in the commands.
Steps
From the repository root, compile a single Cairo file to Sierra with the command below.
cargo run --bin cairo-compile -- --single-file /path/to/input.cairo /path/to/output.sierra --replace-idsCompile that Sierra file to CASM with the command below.
cargo run --bin sierra-compile -- /path/to/input.sierra /path/to/output.casmAlternatively, run a Cairo file directly with the command below.
cargo run --bin cairo-run -- --single-file /path/to/file.cairo
Expected outcome
The documented workflow produces Sierra and CASM files, or invokes the runner on a Cairo file.
Guide limitations
- The commands are repository instructions; this profile does not claim they were executed or verify their results.
- The repository points to its runner README and examples for further usage details.
Compile a Starknet contract
Compile a Starknet contract to a Sierra ContractClass and then to CASM.
Before you start
- Install Rust and set up the stable toolchain.
- A Starknet contract supplied as a crate/project path or a single Cairo file.
Steps
Compile a project path with the command below, or use
--single-filefor a.cairoinput.cargo run --bin starknet-compile -- /path/to/input/crate /path/to/output.jsonIf the project contains multiple contracts, add
--contract-path path::to::contractto select one.Compile the resulting ContractClass with the command below.
cargo run --bin starknet-sierra-compile -- /path/to/input.json /path/to/output.casm
Expected outcome
The documented stages create a Sierra ContractClass JSON file and a CASM CompiledClass output.
Guide limitations
- The README documents compilation stages, not deployment or interaction with a Starknet network.
- These instructions are source-based guidance, not a claim of successful execution.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 22 October 2026
- Original website title
- starkware-libs/cairo · Official homepage title · retained in its source language

