Cairo and StarkNet Contract Development
How Cairo as a language differs from Solidity and Rust, why account abstraction is native to StarkNet, and what writing production StarkNet contracts actually involves.
The basics
Cairo's Position in the Language Landscape
Cairo is StarkNet's smart-contract language, designed by Starkware specifically to translate efficiently into STARK proofs. Cairo 1.0 (released 2023, with continued evolution into Cairo 2.x) is a Rust-inspired language that produces compact, prover-friendly bytecode. The trade-off vs Solidity: Cairo isn't EVM-compatible, so Solidity contracts can't be ported directly; they must be rewritten. The benefit: a language designed around the cost of STARK proving.
What Makes Cairo Different
Cairo borrows much from Rust: ownership rules, traits, pattern matching, immutability by default. But it's specialised for the STARK proving system. Some operations that are cheap in Solidity (modular arithmetic) translate easily; others (bitwise operations, byte manipulation) are more expensive in Cairo because they translate poorly to polynomial constraints. Production Cairo development requires thinking about both correctness and proving cost — a different mental model than Solidity gas optimisation.
Account Abstraction Native
Every account on StarkNet is a smart contract. There are no EOAs. This means signature verification and other validation rules are defined by your account contract, while fee charging (in STRK) and the sequential nonce check remain at the protocol level. Different wallets (Ready, from Argent Labs; Braavos) provide different account implementations with different features (multi-sig, social recovery, session keys, passkeys). Cairo's account-abstraction-native design is structurally cleaner than Ethereum's ERC-4337 retrofit.
- Cairo 1.0+ is Rust-inspired, designed for STARK proving efficiency
- Not EVM-compatible; Solidity contracts must be rewritten
- Account abstraction is the only option — no EOAs
- Production wallets (Ready, from Argent Labs; Braavos) leverage AA-native design for UX features
Key Takeaways
- Cairo is Rust-inspired and designed for STARK proving
- Not EVM-compatible — porting from Solidity requires rewriting
- Every account is a contract; account abstraction is structural, not opt-in
- Production Cairo development requires considering both correctness and proving cost
Going deeper
Cairo Storage and Memory Models
Cairo has explicit storage (persistent contract state, similar to Solidity storage) and memory (transaction-scoped). Storage variables are declared in `#[storage]` blocks; access requires Cairo's storage primitives. The compiler enforces explicit handling of these distinctions, preventing common confusion. Storage layout matters for upgradeability, so the same care is needed as with Solidity's slot-based layout.
Traits and Generic Programming
Cairo borrows Rust's trait system. A trait defines methods that types can implement; generic functions can require their type parameters to implement specific traits. This makes Cairo code more composable than Solidity at the language level — you can write generic vault implementations that work across token types, generic governance modules that work across voting systems, etc. The trade-off is steeper learning curve for developers coming from Solidity's simpler model.
ABI and Interaction
StarkNet contracts have ABIs (Application Binary Interfaces) similar to Ethereum, but with different encoding. Starknet.js (the JavaScript SDK) handles ABI encoding/decoding for clients. Cross-contract calls work similarly to Solidity but with Cairo-specific syntax. Differences in calldata encoding mean that direct hex-level interaction (e.g., from a raw RPC) is more involved than on Ethereum.
Cairo 0 vs Cairo 1+
Cairo 0 was the original language used through 2022. Cairo 1 was a major redesign released 2023, much more Rust-like, with significantly improved tooling. Most current development uses Cairo 1+ (now at Cairo 2.x). Some legacy contracts still use Cairo 0 syntax — be aware of the version when reading documentation or tutorials. The two are not source-compatible.
Key Takeaways
- Storage and memory models are explicit in Cairo — fewer accidental confusions
- Traits enable composable generic programming similar to Rust
- ABI encoding differs from Ethereum; SDKs (Starknet.js) abstract this for clients
- Cairo 0 vs Cairo 1+ are different languages; current development is Cairo 1+
Under the hood
Writing Account Contracts
Implementing a custom account contract on StarkNet means implementing the account entry points (`__validate__` and `__execute__`, plus `__validate_declare__` and `__validate_deploy__` for declare and deploy transactions) — defining how the account validates transactions and executes them. Production accounts (Ready, from Argent Labs; Braavos) implement complex logic: multi-sig support, session keys with limited authority, gas estimation, escape hatches for stuck keys. Writing a custom account is non-trivial but the structure is well-defined. This is where StarkNet's AA-native design shines: account logic is just another contract.
Gas and Resource Model
StarkNet's fee model is multi-resource: L2 gas (computation and L2 data), L1 data gas (state diffs posted to L1) and L1 gas (L2-to-L1 messages), with fees charged in STRK. Understanding cost requires thinking about both execution and L1 data components. Users see a single fee; developers and protocol designers need all three dimensions in mind.
Testing and Tooling
Testing frameworks for StarkNet have matured significantly. starknet-foundry (similar to Foundry on Ethereum) is the leading framework — fast tests, fuzz testing, snapshot testing. scarb is the package manager (analogous to Cargo). starknet-devnet is the local development chain. The tooling ecosystem is now genuinely competitive with EVM tooling, though smaller in community size. Major Cairo projects ship CI/CD pipelines comparable to professional EVM teams.
Migration From Solidity
Teams moving from Solidity to Cairo face real friction. Mental models for storage, gas, error handling, and composition all shift. Documentation has improved substantially through 2024-2025 but there's no automated conversion — every contract is a rewrite. For Solidity-fluent developers, expect a real learning curve on the first project.
STARK Proofs Are Public
STARK proofs make StarkNet scalable but they don't make it private. Every transaction's details are public on-chain, just like Ethereum. Aleo, Aztec, Penumbra are the privacy-focused ZK chains; StarkNet is the scaling-focused one. Don't conflate them. Starknet's docs describe a separate Starknet Privacy protocol (a privacy pool contract with a compliance layer, deployed on mainnet) for private transfers, but ordinary Starknet transactions remain public.
Key Takeaways
- Implementing custom account contracts is structured but non-trivial
- Fee model has three resources (L2 gas, L1 data gas, L1 gas), with a single user-visible fee
- starknet-foundry + scarb + devnet provide a competitive tooling stack
- Solidity-to-Cairo migration is a rewrite; expect a real learning curve on the first project
- StarkNet uses STARKs for scaling, not privacy — transactions are public
Related Content
Related Coins
Related Topics
Key Terms
2026 Trends
More Topics
Browse all 189 topicsBase Architecture
How Coinbase's Base L2 launched on the OP Stack and has been moving to its own Base-operated stack, how Coinbase's exchange-side integration drives uniquely smooth UX, what the sequencer's centralised reality means today, and the path to a 'stage-2' rollup.
Linea and Polygon zkEVM Compared
How two zkEVMs — Linea (Consensys) and Polygon zkEVM, whose Mainnet Beta sequencer was sunset on 3 July 2026 — compare on EVM-equivalence levels, prover technology, ecosystem strategy, and what each chain's positioning means for users and developers.
Solana Programs and Anchor
How Solana's account model differs from Ethereum's, why Sealevel enables parallel execution, what makes Solana programs feel different to write, and where Anchor fits.
Move Language (Aptos and Sui)
Why Move's resource model fundamentally differs from Solidity, how Aptos and Sui evolved from the same Facebook-origin language, and what 'resources' mean for safety guarantees.
CosmWasm and Cosmos Smart Contracts
How CosmWasm enables smart contracts on Cosmos chains via WebAssembly, what makes the developer experience distinct from EVM, and why Cosmos's sovereign-chain architecture is a different bet from rollup-style scaling.
Cardano Plutus and EUTxO Contracts
How Cardano's Extended UTXO (EUTxO) model differs fundamentally from Ethereum's account model, what writing Plutus contracts actually involves, and why concurrency on Cardano works differently.
NEAR Contract Model
How NEAR's sharded execution, async cross-contract calls, and storage staking model differ from Ethereum and Solana — and what writing production NEAR contracts looks like.
ICP Canister Model
How Internet Computer (ICP)'s canisters fundamentally differ from Ethereum-style smart contracts — combining compute, storage, and HTTP-server-like functionality in a single on-chain primitive.
References & further reading
- primary
- secondary
- primaryStarknet Docs - Accounts
Native account abstraction: required entry points, protocol-level nonces.
- primaryStarknet Docs - Fees
Fee components and units (L2 gas, L1 data gas, L1 gas) and STRK-denominated limits.
- primaryStarknet Docs - Starknet Privacy overview
Privacy pool protocol with compliance layer, live on mainnet.