Cairo is a Rust-inspired language that compiles to bytecode, which runs on the Cairo Virtual Machine. The Cairo Virtual Machine is a zero-knowledge virtual machine (ZKVM) used by the Starknet blockchain for executing smart contracts. In this tutorial series, we do not assume prior experience with Rust or zero-knowledge proofs. However, this tutorial series assumes prior experience with Solidity. We expect that the reader knows how to code an ERC-20 and ERC-721 and has a conceptual idea of how dApps like Uniswap V2 work.
Cairo has been carefully designed to help Solidity developers learn the language quickly, and this series highlights their similarities so that Solidity developers can reuse the mental models gained from Solidity to quickly understand Cairo.
To get started writing Cairo smart contracts, you'll need Scarb (Cairo's package manager and build tool) and Starknet Foundry (a toolchain for developing, deploying, and testing Cairo smart contracts).
The easiest way to install these tools is using starkup, which automatically installs Scarb, Starknet Foundry, and the Cairo compiler in one command.
However, at the time of writing, starkup installs Scarb version 2.11.4 and snforge version 0.48.1.
For this tutorial series, we need Scarb v2.12.0 and snforge v0.48.0 to avoid compatibility issues, as some syntax in this series may cause other versions to behave differently or fail to compile certain examples.
To use these specific versions, we recommend installing via asdf because it allows precise version control and the ability to manage multiple versions of different programming tools. If you don't have asdf installed, follow the installation guide.
Note: This guide uses asdf v0.16.0 or newer. If you're using an older version, we recommend updating to the latest version.
Set up Scarb version v2.12.0:
asdf plugin add scarb