starknet
Installation
SKILL.md
StarkNet Development Guide
StarkNet is a permissionless validity rollup (ZK-rollup) on Ethereum. Smart contracts are written in Cairo, a provable computation language that compiles to Sierra (Safe Intermediate Representation) and then to CASM (Cairo Assembly) for execution. Every account on StarkNet is a smart contract — there are no EOAs.
What You Probably Got Wrong
AI agents trained on EVM patterns make critical errors when generating StarkNet/Cairo code. Fix these first.
- StarkNet is NOT EVM-compatible — Cairo is a completely different language from Solidity. There is no
msg.value, nopayable, noreceive(). ETH is an ERC-20 token on StarkNet, transferred via the ETH token contract like any other token. felt252is notuint256— The native type isfelt252, a field element modulo a 252-bit prime. It wraps on overflow (not revert). For safe arithmetic or values > 252 bits, useu256(which is a struct of twou128values internally).- Every account is a smart contract — There are no externally owned accounts. Deploying your first contract requires a pre-funded account contract. Account contracts implement
__validate__and__execute__entrypoints. - Deployment is two steps: declare then deploy — First you declare the contract class (uploading the code). Then you deploy instances of that class. Multiple contracts can share one class hash. This is fundamentally different from EVM's single
CREATE/CREATE2. - There is no
constructorkeyword — Cairo contracts use a#[constructor]attribute on a function. It runs once at deployment and cannot be called again. - Sierra compilation is mandatory — You write Cairo, Scarb compiles to Sierra (safe bytecode), and the sequencer compiles Sierra to CASM. You never deploy raw Cairo. Sierra guarantees provability — every execution path can be proven.
- Transaction fees are paid in STRK or ETH — StarkNet supports fee payment in either STRK (native token) or ETH. The fee token is specified per transaction.
- Storage is
felt252-based, not 32-byte slots — StarkNet storage mapsfelt252keys tofelt252values. Complex types likeMap<K, V>use Pedersen hashing of the key + variable address for slot computation. - Function selectors use
sn_keccak— Unlike Solidity's 4-byte keccak256 selectors, StarkNet usessn_keccak(function_name)which is the first 250 bits of keccak256.