New: Explore our latest Web3 innovations.Learn More about Ancilar Web3 services

Starknet Architecture: Cairo, STARK Prover, and AA

ZK & Cryptography
2024-01-16
Author:jyotvir
Starknet Architecture: Cairo, STARK Prover, and AA

Starknet's ZK-rollup architecture unpacked: Cairo 2.x Sierra/Casm pipeline, STARK prover internals, native account abstraction, and starkli deploy. Jan 2024.

Frequently Asked Questions

Starknet uses Cairo 2.x, a Rust-inspired language that compiles to Sierra (Safe Intermediate Representation) and then to Cairo Assembly (Casm). The Sierra layer guarantees every valid Cairo program produces a provable execution trace, preventing unprovable contract states from reaching L1. Cairo 2.x introduced a linear type system, generics, and traits that substantially improve developer ergonomics over Cairo 0.x.
Every Starknet account is a smart contract. There are no externally owned accounts (EOAs). Every account contract must implement two entry points: `__validate__` and `__execute__`. The sequencer calls `__validate__` first to check signature validity, then `__execute__` to run the transaction logic. This allows arbitrary signature schemes, including multisig, WebAuthn/passkeys, and session keys, at the protocol level without any EIP process or protocol upgrade.
SHARP (Shared Prover) is StarkWare's production STARK proof generation service. It aggregates execution traces from multiple Starknet blocks into a single recursive STARK proof and submits that proof to the Ethereum L1 verifier contract. This amortizes L1 proof-verification gas across many transactions. SHARP is also shared across StarkEx-based applications (dYdX v3, Sorare, ImmutableX), allowing non-Starknet traces to contribute to the same proof batch.
Starknet fees have two components: L2 execution gas, billed in STRK or ETH based on Cairo VM step count, builtins used, and storage writes; and L1 data availability cost. From Starknet v0.13.0 onward, with EIP-4844 blob support introduced in March 2024, L1 DA cost uses blob space at blob-gas price rather than calldata gas, reducing data fees by 5 to 10 times under normal market conditions.
Sierra (Safe Intermediate Representation) is a typed intermediate language between Cairo 2.x source and Cairo VM bytecode. Its defining property is that every Sierra program is guaranteed to compile to a valid, provable execution trace. Casm (Cairo Assembly) is the final bytecode that the Cairo VM executes. The Sierra-to-Casm compilation step is performed by the sequencer at declare time, not by the contract deployer, which is why the DECLARE transaction carries Sierra rather than Casm.

Don't Miss What's Next

Subscribe to newsletter

Tags:

starknet

cairo

stark-prover

account-abstraction

zk-rollups

layer2

blockchain-engineering

Get in Touch

Our team will get back to you within 24 hours.

A clear proven process, that delivers

End of Scroll. Start of Discovery.

You've seen our ideas - now go deeper.
Discover more insights, tutorials, and innovations shaping Web3.