StarkNet: Decentralized ZK-Rollup Using STARK Proofs
StarkNet is a permissionless decentralized ZK-rollup that uses STARK proofs to batch thousands of transactions off-chain and submit a single proof to Ethereum. It supports general-purpose smart contracts written in Cairo.
StarkNet: Decentralized ZK-Rollup Using STARK Proofs
StarkNet is a permissionless decentralized ZK-rollup operating on Ethereum. It uses STARK cryptographic proofs to batch thousands of transactions off-chain and submit a single validity proof to Ethereum. This enables scalable, low-fee transactions while inheriting Ethereum's security. Unlike optimistic rollups, StarkNet provides instant finality and faster withdrawals because transactions are cryptographically proven. StarkNet supports general-purpose smart contracts written in Cairo, a Turing-complete programming language designed for STARK-provable computations. It is a major scaling solution for Ethereum, alongside zkSync and Arbitrum.
To understand StarkNet properly, it helps to be familiar with zk-STARKs, ZK-rollups, and Ethereum fundamentals.
┌─────────────────────────────────────────────────────────────────────────┐
│ StarkNet Architecture │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ Users ──→ StarkNet Sequencer (off-chain) │
│ │ │
│ ▼ │
│ Batch of transactions (thousands) │
│ │ │
│ ▼ │
│ Cairo VM execution (state update) │
│ │ │
│ ▼ │
│ STARK proof generation │
│ (validity proof) │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Ethereum L1 │ │
│ │ ┌─────────────────────────────────────────────────────────────┐│ │
│ │ │ StarkNet Core Contract ││ │
│ │ │ • Verifies STARK proof ││ │
│ │ │ • Updates state root ││ │
│ │ │ • Processes deposits/withdrawals ││ │
│ │ └─────────────────────────────────────────────────────────────┘│ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
│ Key Features: │
│ • Permissionless (anyone can deploy contracts) │
│ • STARK proofs (no trusted setup, quantum-resistant) │
│ • Cairo language (Turing-complete, provable) │
│ • Account abstraction (native) │
│ │
└─────────────────────────────────────────────────────────────────────────┘
What Is StarkNet?
StarkNet is a decentralized ZK-rollup that scales Ethereum using STARK proofs. It operates as a Layer 2 network where transactions are executed off-chain, batched, and proven with a STARK validity proof before being settled on Ethereum. Anyone can deploy smart contracts on StarkNet using the Cairo programming language. The network is permissionless, meaning no central operator controls who can transact or deploy contracts. StarkNet inherits Ethereum's security because the L1 contract verifies proofs cryptographically. Validium mode is also available (data off-chain) for even higher throughput.
- STARK Proofs: Zero-knowledge proofs with no trusted setup, post-quantum resistant, scalable prover (O(n log n)). Used to prove correctness of transaction batches.
- Cairo Language: Turing-complete language for writing provable programs. Compiles to CASM (Cairo Assembly) executed on Cairo VM. Supports complex logic (loops, recursion, arrays).
- Account Abstraction: Every account is a smart contract (not EOA). Supports signature verification, multisig, social recovery natively. Better user experience (custom fee tokens).
- Decentralized Sequencer: StarkNet uses decentralized sequencer (not centralized operator). Anyone can become sequencer (in progress, currently centralized transition).
Why StarkNet Matters
StarkNet provides scalability for Ethereum without sacrificing security or decentralization, using the most advanced ZK proofs.
- High Throughput (Scalability): Thousands of transactions per second (vs Ethereum L1 15 TPS). Each batch can contain millions of Cairo steps (steps are cheaper than EVM gas).
- Low Fees: Transaction fees are fractions of a cent (vs $1-50 on L1). Batching amortizes L1 verification cost across many users. Fees paid in ETH or custom tokens (via account abstraction).
- No Trusted Setup (Transparent): Unlike zk-SNARK-based rollups (zkSync, Polygon zkEVM have trusted setups). STARK proofs require no trusted setup, more transparent.
- Instant Finality (No Challenge Period): Validity proofs guarantee correctness immediately. Withdrawals final once proof verified (minutes vs 7 days). Better capital efficiency (fast exits).
- Quantum-Resistant (Long-term Security): STARKs based on hash functions, quantum resistant. zk-SNARKs vulnerable to Shor's algorithm. Future-proof security.
Feature StarkNet zkSync Era Optimistic (Arbitrum)
──────────────────────────────────────────────────────────────────────────────────────────
Proof Type STARK (ZK) SNARK (ZK) Fraud proof
Trusted Setup None Yes N/A
Withdrawal Delay Minutes (proof) Minutes 7 days
EVM Compatibility No (Cairo) Yes (zkEVM) Yes (full EVM)
Post-Quantum Yes No N/A
Account Abstraction Native Limited No
Transaction Cost Very low Very low Low
Sequencer Decentralized (in prog) Centralized (now) Decentralized
Cairo Programming Language
Cairo (CPU Air) is a Turing-complete language for writing STARK-provable programs. It is the primary language for StarkNet smart contracts. Cairo is not EVM-compatible, requiring developers to learn new syntax. StarkNet uses Cairo 1.0 (Rust-like syntax, safer than older version).
#[starknet::contract]
mod Counter {
#[storage]
struct Storage {
count: u32,
}
#[external]
fn increase_counter(ref self: ContractState) {
self.count.write(self.count.read() + 1);
}
#[external]
fn get_counter(self: @ContractState) -> u32 {
self.count.read()
}
}
#[starknet::interface]
trait IERC20 {
fn transfer(ref self: TContractState, recipient: ContractAddress, amount: u256);
fn balance_of(self: @TContractState, account: ContractAddress) -> u256;
}
#[starknet::contract]
mod ERC20 {
#[storage]
struct Storage {
balances: LegacyMap::,
total_supply: u256,
}
#[external]
fn transfer(ref self: ContractState, recipient: ContractAddress, amount: u256) {
let sender = get_caller_address();
let sender_balance = self.balances.read(sender);
assert(sender_balance >= amount, 'Insufficient balance');
self.balances.write(sender, sender_balance - amount);
self.balances.write(recipient, self.balances.read(recipient) + amount);
}
#[external]
fn balance_of(self: @ContractState, account: ContractAddress) -> u256 {
self.balances.read(account)
}
}
Cairo vs Solidity
| Aspect | Cairo (StarkNet) | Solidity (Ethereum) |
|---|---|---|
| Type System | Strongly typed, Rust-like | Loosely typed, implicit conversions |
| Storage Model | Explicit read/write, contract state | Implicit, state variables |
| Account Model | Account abstraction natively | EOA + contract accounts |
| Execution Model | Cairo VM (provable) | EVM |
| Gas Model | Step-based (Cairo steps) | Gas (opcode-based) |
| Tooling | Starkli, Scarb, Snforge | Hardhat, Foundry, Truffle |
StarkNet Development Tools
Starkli (CLI):
• Deploy contracts
• Interact with StarkNet
• Manage accounts
Scarb (Build tool, Rust-inspired):
• Dependency management
• Compilation (Cairo → Sierra → CASM)
• Testing (Snforge integration)
Snforge (Testing framework):
• Unit tests
• Integration tests
• Cheatcodes (mock caller, block info)
StarkNet Devnet (Local node):
• Local StarkNet instance for development
• Fast iteration (no testnet latency)
Voyager (Block explorer):
• View transactions, contracts, state
• Verify contracts (source code)
StarkNet Anti-Patterns
- Writing Solidity on StarkNet (Not Understanding Cairo): Cairo is not EVM-compatible, patterns differ. Expect different gas costs (Cairo steps vs EVM gas). Learn Cairo idioms (storage, events).
- Ignoring STARK Proof Costs (Gas Estimation): STARK proof generation has fixed cost per batch, amortized across transactions. Transaction gas depends on Cairo steps (not just data). Use step estimator to estimate fees.
- Not Using Account Abstraction (EOA Mentality): Every account is a contract, EOA does not exist. Leverage signature verification, multisig, custom fee tokens. Many projects still use basic EOA-like patterns (missing benefits).
- Over-optimizing for EVM Gas (Using Wrong Metrics): Cairo VM has different cost model: steps are cheap, storage reads more expensive. Optimize for steps reduction, not EVM gas.
- Not Testing with Realistic Volumes: Small-scale tests pass but large batches reveal step limits. Test with load (many transactions). Monitor step usage.
Environment Setup:
□ Install Starkli, Scarb
□ Configure account (deploy or declare)
□ Set up local Devnet for testing
Contract Development:
□ Write Cairo contract
□ Unit tests with Snforge
□ Estimate steps (gas)
□ Deploy to testnet (Sepolia)
Security:
□ Audit Cairo contracts (different from Solidity)
□ Check for reentrancy (Cairo protects? no, be careful)
□ Validate inputs (caller address, amounts)
□ Use OpenZeppelin Cairo contracts
Deployment:
□ Declare contract class (upload code)
□ Deploy instance (create)
□ Verify on Voyager
Operations:
□ Monitor transactions (Voyager)
□ Handle upgrades (if proxy pattern used)
□ Plan for sequencer decentralization
StarkNet Best Practices
- Use OpenZeppelin Cairo Contracts: Audited implementations for ERC-20, ERC-721, Ownable, AccessControl. Reduces risk of vulnerabilities.
- Leverage Account Abstraction (Custom Validation): Implement multisig wallets natively, social recovery, session keys for gaming, and fee abstraction (pay fees in custom token).
- Estimate Steps Before Deployment: Use `starkli estimate` to approximate gas (Cairo steps). Ensure function step count acceptable (less than block step limit). Monitor step usage in production.
- Test on StarkNet Devnet (Local): Faster iteration than Sepolia testnet. Simulate failures, edge cases, and use cheatcodes (mock block numbers, caller addresses).
- Use Snforge for Comprehensive Testing: Write unit tests for each function, integration tests for multi-contract interactions, and fuzzing for invariant testing.
- Monitor Transaction Status (Voyager): Track pending, accepted on L2, accepted on L1. Ensure transactions finalize (L1 acceptance).
Documentation:
• Cairo Book (official)
• StarkNet Book (official)
• StarkNet by Example (code examples)
Community:
• StarkNet Discord
• StarkNet Stack Exchange
• StarkNet Twitter (@StarkNet)
Example Projects:
• OpenZeppelin Cairo contracts
• Briq (NFT building protocol)
• Realms (on-chain game)
StarkNet Roadmap
StarkNet is actively evolving toward full decentralization. Current status (2024): Mainnet with centralized sequencer. Next steps: decentralized sequencer (multiple operators), permissionless proving (anyone can generate proofs), and dynamic fees (based on L1 gas). Cairo 1.0 is stable, replacing older Cairo 0.x (deprecated). Volition support (choose data availability: rollup or validium per transaction) is planned.
Aspect StarkNet zkSync Era
─────────────────────────────────────────────────────────────────────────────
Proof System STARK SNARK (PLONK)
Trusted Setup None Yes (universal)
EVM Compatibility No (Cairo) Yes (zkEVM)
Account Abstraction Native Limited
Post-Quantum Yes No
Maturity Growing (decentralizing) Mainnet (centralized)
Ecosystem Smaller, growing Larger (EVM tools)
Frequently Asked Questions
- Do I need to learn Cairo to use StarkNet?
Yes. StarkNet does not support Solidity. You must write contracts in Cairo. Cairo has learning curve (Rust-like syntax, provable programming). Benefits: STARK proofs, account abstraction, post-quantum security. - Is StarkNet decentralized?
Partially (2024). Sequencer is centralized (single operator StarkWare). Planned: decentralized sequencer set (multiple operators). Prover can be anyone (permissionless proving upcoming). Ethereum L1 settlement is decentralized. - How do I bridge funds to StarkNet?
Official StarkGate bridge (ETH, ERC-20 tokens). Supported tokens: USDC, DAI, wBTC, and others. Withdrawal time: minutes (after proof finalization). - What is the difference between StarkNet and StarkEx?
StarkEx is an application-specific rollup engine (custom for dYdX, Immutable X). StarkNet is general-purpose (anyone can deploy contracts). StarkEx is permissioned (custom per app); StarkNet is permissionless. - Can I deploy existing Solidity contracts to StarkNet?
No, not directly. Need to rewrite in Cairo. Some tools help transpile but not production ready. Use zkSync Era for Solidity compatibility. - What should I learn next after StarkNet?
After mastering StarkNet, explore Cairo programming language, advanced StarkNet contract patterns, account abstraction (signature verification, multisig), local development with Devnet, and STARK proof generation.
