Ethereum News
Starknet’s Cairo programming language for ZK-rollups explained

Scaling Ethereum with ZK proofs
Starknet scales Ethereum by processing transactions off-chain and using ZK proofs. It processes thousands of transactions per second, while the Ethereum mainnet handles between 15 and 30. Rollups use off-chain software to verify and organize crypto transfer data, and they use smart contracts to communicate with the L1 blockchain. Starknet produces STARK proofs off-chain and sends them to the Ethereum mainnet to finalize transactions, which reduces the computational stress on the main blockchain and lowers gas fees for all users. ZK proofs allow a prover to show a verifier they have knowledge without revealing the knowledge itself. In a ZK system, the verifier checks if the proof follows the rules. Because the verifier only checks the proof, they do not learn details about the transactions. ZK rollups use this to bundle transactions off-chain. This method reduces the burden on Ethereum. ZK-SNARKs are smaller and consume less gas to generate and verify proofs. However, ZK-SNARKs can require a trusted setup and carry centralization risks. ZK-STARKs are more decentralized and resistant to quantum attacks. Starknet uses the STARK proof system.
The Cairo 1.0 programming language
Cairo 1.0 is the native language for the Starknet Layer-2 network. This version arrived in 2023 as a brand new language rather than an iteration. Over 90% of the code draws inspiration from the Rust language. It is a STARK-based, Turing-complete language used to write programs that are provable through mathematical arguments. One party proves to another that a computation executed correctly. The language uses a linear type system to prevent runtime errors. This system ensures a value cannot be used twice. If a user writes to a memory cell twice, the compiler detects the error. The language uses ownership rules to manage memory without a garbage collector. Each value has an owner, only one owner exists at a time, and the value disappears when the owner goes out of scope.
You should know that developers must learn Cairo to build on Starknet, as it differs from the Solidity used on other ZK-rollups. Cairo 1.0 includes several data types. Basic types include Boolean, Never, Unit, and Numeric types like felt252 and integers. Sequence data types include Tuples, Arrays, and Felt252Dict. Pointer data types include Box and Snapshot. User-defined types include Structs and Enums. The transition from the original Cairo version to Cairo 1.0 involves using Sierra, an intermediate representation known as Safe Intermediate Representation, which the sequencer compiles into assembly. This architecture ensures the integrity of the code. The language maintains a Goldilocks principle by using a minimal instruction set to perform low-level operations. It includes a register list with PC, allocation pointer, and frame pointer. It supports functions, recursion, and random memory.
ZK rollups and optimistic alternatives
ZK rollups and optimistic rollups use different verification methods. ZK rollups work on a "guilty until found innocent" principle, where they consider every transaction fraudulent by default and require the network to prove otherwise. They use validity proofs to attest to the accuracy of a transaction batch. Optimistic rollups assume transactions are valid by default and rely on fraud proofs. Optimistic rollups require a challenge period. Users might wait over a week for an optimistic rollup to clear on the mainnet. ZK rollups require more computational power than optimistic rollups. This high hardware requirement means fewer people join ZK networks. Developers find it easier to port Ethereum dApps into optimistic rollup platforms than re-coding projects for a ZK rollup system. However, ZK rollups are more censorship-resistant because sequencers cannot exclude transactions by altering the generated proofs. ZK rollups do not rely on game theory to prove transaction sets. Some ZK rollup implementations also provide enhanced privacy features. Will the move to native execution eventually eliminate the need for the Cairo VM?
Technical specifications and fees
Starknet uses gas to pay for resources. For v3 transactions, users pay in STRK. The network uses L2 gas to pay for computation, transaction payload, and event emission. A single Cairo step costs 100 L2 gas. This is equivalent to 0.0025 L1 gas.
| Attribute | Value |
|---|---|
| Ethereum TPS | 15 – 30 |
| Starknet TPS | Thousands |
| Cairo 1.0 inspiration | 90% Rust |
| 1 Cairo step | 100 L2 gas |
| 1 Cairo step | 0.0025 L1 gas |
One Cairo step is 100 L2 gas. The cost of other resources depends on their current L1 gas cost. One Cairo step is 0.0025 L1 gas.