WELCOME TO CAIRO

The Rust-inspired language that makes it easy to build scalable dApps with the power of validity proofs.

What is cairo?

Cairo lets you write provable programs without requiring a deep understanding of the underlying ZK concepts. From onchain gaming to provable ML, Cairo makes building trustless applications possible.

Cairo is also the smart-contract language of Starknet, an L2 blockchain that is verified over Ethereum.

why use cairo?

  • Hand snapping

    Developer-Friendly

    Write Rust-like code and generate proofs for program execution—math isn’t a barrier.

  • Stopwatch

    Efficient

    Cairo compiles down to an ad-hoc assembly, which was engineered specifically for efficient proof generation.

  • Triple arrow

    Innovative

    Unshackled by EVM,
    Cairo is a fast-growing language that keeps delivering new and exciting features to its developers.

Book
Book

The Cairo Book will walk you through setting up your environment and writing your first Cairo program, and then proceed to give a thorough overview of the language.

Read the Book

Cairo on Starknet

Starknet is an L2 Validity Rollup that operates on top of Ethereum, enabling dApps to massively scale without compromising on security or decentralization.

Cairo is Starknet's smart-contract language. Cairo is purpose-built for provable computing and is a cornerstone in Starknet’s ability to scale blockchains.

Contribute to Cairo’s development

You can play a crucial role in building the foundation for a scalable and secure blockchain ecosystem—let's innovate together.

GET SUPPORT

For questions or inquiries about Cairo, reach out to us on Discord or Stack Overflow.

Community
Community

To get involved with the growing Cairo community, join our community forum and check out our upcoming events.

Frequently asked questions

Here are some short answers to common questions related to Cairo.

Can’t find what you’re looking for?

Check our community forum
  1. What is Cairo?

    Cairo is a programming language for writing provable programs. Using Cairo, you don’t have to trust that the result of a complex computation is 42, you can know that running the computation results in 42, without having to run it yourself.

    Cairo is also the smart-contract language of Starknet, a Validity Rollup (aka ZK-Rollup) layer 2 on top of Ethereum.

  2. How can I get started with Cairo?

    Get started with Cairo by following this tutorial.
    Find more Cairo tutorials in the Resources page.

  3. What is Cairo used for?

    Offchain, any application that is based on one party verifying large computations without re-executing them from scratch can use Cairo. From verifiable cloud to provable ML, Cairo removes the need for trusting a third party (verify, don’t trust)

    Onchain, Cairo is used for numerous applications that used to be prohibitively expensive due to gas costs: onchain games, smart accounts, and DeFi solvers - all benefit from using Cairo.

  4. What is CASM and Sierra in Cairo?

    Cairo is more than a programming language - it’s an entire CPU architecture whose instruction set is known as CASM (Cairo assembly). Cairo programs compile to an intermediate representation called Sierra (Safe IntermediatE RepResentAtion), which in turn compiles to CASM. That is, we have two compilation processes involved: Cairo → Sierra, and Sierra → CASM.

    The safety that Sierra provides is that any CASM generated by the Sierra→CASM compiler can be proved, which is a crucial property in the context of blockchains. You can read more about it in the Starknet docs.

    The prover actually knows nothing about high-level Cairo, we can only prove CASM execution. High level Cairo exists to improve developer experience while still enabling efficient proving.

  5. What is the difference between Cairo and CairoZero?

    CairoZero was the first iteration of the Cairo language and is no longer maintained.
    The latest version of Cairo is more ergonomic, has a Rust-like syntax, and overall offers a much better developer experience.

  6. How is Cairo different from other programming languages?

    Cairo is optimized for proving the execution of programs using STARK technology. When talking about proofs, “performance” takes a different turn compared to common programming languages. Cairo emphasizes proving efficiency rather than on the execution efficiency.

    That said, Cairo abstracts away the cryptography and math involved in proof generation. Cairo allows developers who are not familiar with the zk-proofs world to immediately dive in and start writing code.

  7. How do I set up a Cairo environment?

    You can use Scarb, Cairo’s package manager, to create a new package and write your first Cairo program. Install Scarb.

  8. What is the difference between zkEVM and the CairoVM ?

    zkEVM refers to a group of projects and solutions whose goal is to prove EVM execution. The CairoVM is a completely different VM (with a different instruction set and memory model) that emphasizes optimizing proving efficiency.

    While zkEVM focuses on Ethereum compatibility, it sacrifices performance and scalability. On the other hand, the Cairo VM, used in Starknet, prioritizes performance and scalability over compatibility.