Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Glossary

Cairo

Cairo is a Turing-complete programming language and framework designed for writing provable programs, primarily used to develop smart contracts for the StarkNet zk-rollup, where execution is verified using STARK proofs.
Chainscore © 2026
definition
BLOCKCHAIN PROGRAMMING LANGUAGE

What is Cairo?

Cairo is a Turing-complete, high-level programming language designed specifically for creating provable programs, primarily for StarkNet and StarkEx scalability solutions on Ethereum.

Cairo is a Turing-complete, high-level programming language designed for writing provable programs, where the correctness of execution can be cryptographically verified. It is the native language for StarkNet, a permissionless decentralized Validity-Rollup (ZK-Rollup), and StarkEx, a scaling engine, both of which use STARK proofs to scale Ethereum. Unlike general-purpose languages, Cairo's syntax and architecture are built from the ground up to generate computational integrity proofs, enabling complex dApp logic to be executed off-chain and verified on-chain with minimal gas cost.

The language employs a unique AIR (Algebraic Intermediate Representation) to describe computations. When a Cairo program runs, it produces an execution trace. This trace is used to generate a STARK proof, a succinct cryptographic certificate that attests to the correct execution of the program without revealing its inputs. This core mechanism allows for massive scalability—proving the validity of thousands of transactions in a single proof—while maintaining Ethereum's security guarantees through cryptographic assurance rather than re-execution.

Cairo 1.0, a major revision, introduced a Rust-inspired syntax and a powerful borrow checker, significantly improving developer experience and safety. It compiles down to Sierra, a safe intermediate representation, which then compiles to Cairo Assembly (CASM), the bytecode executed by the Cairo VM. This layered compilation ensures that programs are always provable. Key use cases include building high-throughput DeFi protocols, gaming engines, and privacy-preserving applications on StarkNet, where computational integrity and low costs are paramount.

etymology
CAIRO

Etymology and Origin

The name 'Cairo' for StarkWare's programming language and virtual machine is a deliberate choice, rich with historical and technical metaphor.

Cairo is a Turing-complete programming language and virtual machine designed by StarkWare for creating STARK-provable programs, primarily for blockchain scaling. The name is a direct reference to the Cairo Geniza, a collection of medieval Jewish manuscript fragments discovered in the Ben Ezra Synagogue in Old Cairo, Egypt. This historical repository was significant for preserving a vast, fragmented record of a community's life and law. Similarly, the Cairo language is built to generate concise cryptographic proofs—succinct, verifiable records—of computational integrity, preserving the essential truth of complex computations without storing their entire execution trace.

The choice of name extends beyond mere historical allusion to a core technical analogy. Just as the Geniza fragments provided verifiable evidence of historical events and transactions, a Cairo program produces a STARK proof that serves as irrefutable, compact evidence that a computation was executed correctly. This proof can be verified by anyone far more efficiently than re-running the original program, enabling the validity rollup scaling paradigm. The language's architecture, including its AIR (Algebraic Intermediate Representation) and built-in proof system, is engineered from the ground up to make this proof generation as efficient as possible.

The development of Cairo is intrinsically linked to the evolution of StarkNet, a decentralized Layer 2 validity rollup on Ethereum. Cairo serves as StarkNet's native smart contract language, with contracts compiled to Cairo assembly and executed within the Cairo VM. Its design emphasizes safety and provability, featuring a memory model that prevents undefined behavior and built-in primitives for cryptographic operations. This makes it distinct from general-purpose languages like Solidity, as every Cairo program is, by construction, a blueprint for a zero-knowledge proof.

Understanding Cairo's origin clarifies its role in the broader blockchain ecosystem. It is not merely another smart contract language but a foundational tool for verifiable computation. Its etymology underscores a fundamental shift in blockchain design: moving from trusting a network of re-executing nodes to trusting cryptographic truth. As such, Cairo is central to realizing the vision of StarkWare and similar projects, where scalable blockchains can maintain security by publishing and verifying these compact proofs of validity, much like scholars verifying history through fragmented but conclusive evidence.

key-features
CAIRO

Key Features

Cairo is a Turing-complete, high-level programming language and framework for creating provable programs (STARKs) on Starknet and other validity rollups. It enables developers to write complex, verifiable logic for decentralized applications.

01

Provable Computation

Cairo's core innovation is enabling STARK-based proofs. It compiles code into a format where the execution trace can be cryptographically proven correct off-chain. This allows for:

  • Validity proofs (e.g., StarkEx, Starknet) that verify state transitions.
  • Scalability by moving computation and verification off the base layer (L1).
  • Privacy potential, as proofs can verify execution without revealing all input data.
02

Built-in Proof System

Unlike EVM languages, Cairo has a built-in proof system. The Cairo Virtual Machine (CVM) executes programs and generates a trace that is inherently compatible with the STARK proof system. This means:

  • Developers write business logic; the framework handles proof generation.
  • Enables recursive proofs (proofs of proofs) for infinite scalability.
  • The Cairo AIR (Algebraic Intermediate Representation) is the constraint system that defines correct execution.
03

Memory Model: Immutable & Continuous

Cairo uses a continuous, immutable memory model. Memory is a single, write-once array where each cell has a unique, sequential address. This design is crucial for efficient proof generation. Key aspects include:

  • Non-deterministic hints: The prover can provide off-chain information to guide execution, which is then verified.
  • Deterministic execution: The verifier checks the proof against the public input and memory commitments, ensuring the hinted execution was correct.
04

Cairo Native & Sierra

The language is evolving for better developer experience and performance.

  • Cairo Native: A Rust-based compiler that allows Cairo programs to run outside the CVM for faster local testing and execution.
  • Sierra (Safe Intermediate Representation): A higher-level IR between Cairo and bytecode. It prevents runtime failures by ensuring all Cairo-level operations have a valid compilation path, eliminating 'panic' states on Starknet.
05

Account Abstraction Native

Cairo and Starknet have native account abstraction. Smart contract accounts are the primary account type, enabling:

  • Sponsored transactions: A third party can pay fees.
  • Multi-signature & social recovery: Custom security logic.
  • Transaction batching: Multiple actions in a single transaction.
  • Signature abstraction: Support for any signature scheme (e.g., ECDSA, EDDSA). This is a fundamental architectural difference from the EOA model of Ethereum.
how-it-works
PROGRAMMING LANGUAGE

How Cairo Works

Cairo is a Turing-complete, high-level programming language designed to write provable programs for the Starknet L2 and StarkEx L3 blockchains.

Cairo enables developers to write STARK-provable programs, where the correctness of a computation is verified cryptographically without re-executing it. This is achieved by generating a computational integrity proof, known as a STARK proof, which attests that a program was executed correctly given specific inputs. The language's syntax is designed to be expressive for general-purpose computing while being constrained enough for efficient proof generation. A Cairo program is compiled into Cairo Assembly (CASM), a lower-level representation that the Cairo VM executes to produce an execution trace for the prover.

The core of Cairo's architecture is the Cairo Virtual Machine (CVM), a specialized VM that processes Cairo bytecode. Unlike traditional VMs, the CVM's execution is structured to produce a trace that is amenable to efficient cryptographic proving. The prover uses this trace to generate a STARK proof, a small cryptographic certificate that can be verified in milliseconds, even for complex computations. This decouples execution from verification, allowing a single proof to convince countless verifiers of the result's validity, which is the foundation of Starknet's scalability.

Cairo operates on a shared prover model, where many transactions are batched together into a single proof. This aggregation dramatically reduces the cost per transaction. The language is memory-safe and includes native support for felt (field element) data types, which are the fundamental units of computation within the STARK-proof-friendly prime field. Developers interact with Cairo through tools like the Cairo compiler (cairo-compile), the Cairo test runner, and integrated development environments, which handle the translation from high-level code to a provable execution trace.

A key innovation in Cairo 1.0 and later versions is the Sierra intermediate representation layer. Sierra sits between the high-level Cairo code and the low-level CASM, providing a safety layer that guarantees that every valid Sierra program can be compiled to provable CASM. This eliminates the possibility of compile-time errors in the final proving stage and enhances developer experience. Sierra is also the interface through which Cairo smart contracts on Starknet are executed and proven.

In practice, writing a Cairo program involves defining functions, structs, and using built-in or library functions for operations like hashing and signature verification. When deployed on Starknet, a Cairo contract's state transitions are proven off-chain, and only the proof and the new state root are posted on the Ethereum L1. This mechanism, powered by Cairo's provable execution, enables Starknet to offer high throughput and low transaction fees while maintaining Ethereum-level security through cryptographic verification.

cairo-vs-solidity
PROGRAMMING LANGUAGE COMPARISON

Cairo vs. Solidity: A Paradigm Shift

An analysis of the fundamental architectural differences between Cairo, a language for provable programs, and Solidity, the dominant language for smart contract execution on the Ethereum Virtual Machine.

Cairo is a Turing-complete programming language and framework designed for writing provable programs (often called STARK-provable programs) for general computation, most notably as the native language for StarkNet's Layer 2 validity rollup. In contrast, Solidity is an object-oriented, high-level language created specifically for implementing smart contracts that execute deterministically on the Ethereum Virtual Machine (EVM). This represents a paradigm shift from a virtual machine-centric model (EVM) to a proof-centric model (STARKs), where the primary output is a cryptographic proof of correct execution rather than just a state change.

The core divergence lies in their computational models and trust assumptions. A Solidity contract's logic is executed and validated by every node in the Ethereum network, requiring consensus on the process. Cairo, however, separates execution from verification: a single entity (the prover) executes the program and generates a STARK proof, while any verifier can check this proof's validity in constant time, trusting only the cryptographic soundness of the proof system. This enables Cairo to be more computationally expressive, supporting complex logic like recursive proofs, while Solidity is constrained by the EVM's gas costs and opcode limitations.

This architectural shift manifests in their application domains. Solidity is optimized for the specific domain of on-chain, state-modifying contract logic—managing token balances, decentralized exchange pools, and governance votes. Cairo, through its hierarchical proof system, excels at scaling this logic by batching thousands of transactions into a single proof, and is inherently suited for applications requiring verifiable off-chain computation, such as privacy-preserving proofs or verifiable machine learning models, which are impractical in the EVM environment.

ecosystem-usage
CAIRO

Ecosystem and Usage

Cairo is a Turing-complete, production-ready programming language for creating provable programs, primarily used to write smart contracts and validity proofs for Starknet and StarkEx scaling solutions.

02

StarkEx Prover Circuits

Before Starknet, Cairo was developed to power StarkEx, a scaling engine used by applications like dYdX and ImmutableX. In this context, Cairo programs define the logic for validity proofs that verify the integrity of batched transactions (e.g., trades, NFT mints) off-chain, which are then settled on Ethereum. This demonstrates Cairo's initial use case for high-throughput, application-specific scaling.

04

Tooling & Development Stack

The Cairo ecosystem is supported by a robust developer toolkit:

  • Scarb: The official package manager and build tool for Cairo projects (akin to Cargo for Rust).
  • Protostar & StarkFoundry: Testing and development frameworks.
  • Starkli & Starknet.js: Command-line and JavaScript tooling for deployments and interactions.
  • Voyager & Starkscan: Block explorers for inspecting transactions and contracts on Starknet.
05

Proving Systems Integration

Cairo's design is intrinsically linked to STARKs (Scalable Transparent Arguments of Knowledge). A Cairo program's execution trace is fed into a STARK prover, which generates a cryptographic proof. This proof is then verified on-chain by a STARK verifier contract. This separation allows massive computational work to be done off-chain with a minimal on-chain verification cost.

06

Native Account Abstraction

A major ecosystem differentiator is that account abstraction is not an add-on but a native feature of the Cairo/Starknet model. Every account is a smart contract (written in Cairo), enabling:

  • Custom transaction validation logic (e.g., multisig, social recovery).
  • Sponsored transactions where a third party pays fees.
  • Session keys for improved user experience in gaming and DeFi.
CAIRO

Common Misconceptions

Cairo is a powerful, Turing-complete language for writing provable programs, but its unique architecture and purpose often lead to confusion. This section clarifies key misunderstandings about its capabilities, relationship to StarkNet, and development model.

No, Cairo is a general-purpose programming language for creating STARK-provable programs, which is a broader category than just smart contracts. While it is the primary language for StarkNet smart contracts, Cairo's core function is to generate computational integrity proofs for any computation. This means it can be used for Layer 2 validity proofs, verifiable computation off-chain, and even creating proofs for non-blockchain applications. Solidity, in contrast, is designed specifically for composing execution logic on the Ethereum Virtual Machine (EVM).

CAIRO

Technical Deep Dive

Cairo is a Turing-complete programming language and framework for creating provable programs, primarily used for writing smart contracts and validity proofs on Starknet and other StarkEx-based systems.

Cairo is a Turing-complete, assembly-like programming language designed for writing provable programs, where the correctness of execution can be cryptographically verified by a STARK proof. It works by enabling developers to write logic (like smart contracts) that a prover can compile into a computational trace. This trace is then used to generate a succinct proof, which a verifier can check almost instantly, confirming the program ran correctly without re-executing it. This is the core mechanism enabling scalable ZK-Rollups like Starknet.

CAIRO

Frequently Asked Questions

Cairo is a Turing-complete programming language and framework for creating provable programs, primarily used for developing StarkNet smart contracts. These questions address its core concepts, use cases, and how it differs from other blockchain development environments.

Cairo is a Turing-complete programming language and framework designed for writing provable programs, where the correctness of a computation can be cryptographically verified without re-executing it. It works by enabling developers to write logic (the Cairo program) that is executed to generate an execution trace. This trace is then used by a STARK prover to create a succinct cryptographic proof. A verifier can check this proof to be confident the computation was performed correctly, which is the foundational mechanism for StarkNet validity rollups. This allows for massive scaling by moving computation and state updates off-chain, submitting only the tiny proof to the Ethereum mainnet for verification.

ENQUIRY

Get In Touch
today.

Our experts will offer a free quote and a 30min call to discuss your project.

NDA Protected
24h Response
Directly to Engineering Team
10+
Protocols Shipped
$20M+
TVL Overall
NDA Protected Directly to Engineering Team
Cairo: The Programming Language for StarkNet & zk-Proofs | ChainScore Glossary