LayerZero provides Starknet Cairo Contracts that can communicate with the equivalent Solidity Contract Libraries and Solana Programs deployed on other chains. These contracts, like their Solidity and Rust counterparts, simplify calling the LayerZero Endpoint, provide message handling, interfaces for protocol configurations, and other utilities for interoperability:
- Omnichain Fungible Token (OFT): extends OApp with functionality for handling omnichain token transfers using Starknet’s ERC20 standard.
- Omnichain Application (OApp): the base contract utilities for omnichain messaging and configuration.
Differences from the Ethereum Virtual Machine
The full differences between Solidity/EVM and Cairo/Starknet are significant. For comprehensive guides, see:Skip this section if you already feel comfortable working with Starknet and its account abstraction model.
Comparison Table
| Aspect | EVM | Starknet |
|---|---|---|
| State Model | Storage slots | Felt-based contract storage |
| Language | Solidity | Cairo |
| Authorization | msg.sender | get_caller_address() |
| Cross-Contract | External calls | Dispatcher pattern |
| OApp Identity | Contract address | Contract address |
| Balance Type | uint256 | u256 (struct: two u128) |
| Fee Model | Gas (ETH) | Resource bounds (STRK/ETH) |
| Account Model | EOA + Contracts | Account Abstraction (all accounts are contracts) |
| Deployment | Single transaction | Declare + Deploy (two steps) |
Account Abstraction (No EOAs)
The most fundamental difference is Starknet’s native account abstraction: EVM:- Before deploying any contract, you must have a deployed and funded account contract (wallet)
- Signatures are produced off-chain by the account owner and validated by the account contract
- Account contracts handle fee payment and transaction execution for that account
- Common account implementations include Ready Wallet (formerly Argent), Braavos, and OpenZeppelin Account
Declare Then Deploy Lifecycle
Unlike EVM where you deploy bytecode in a single transaction, Starknet separates code publication from instantiation: Step 1: Declare - Publish your contract code to the network:- class_hash: Unique identifier for your contract’s code (like a “template”)
- contract_address: Specific instance of that code with its own state
- Multiple contracts can share the same class_hash (reusable code)
Dispatcher Pattern vs Inheritance
Starknet uses the dispatcher pattern instead of Solidity’s inheritance model. EVM uses inheritance for contract composition:Constructor Caller Footgun
Problem:Cairo Integer Types
Cairo 1.0 provides native unsigned integer types. For token amounts (ERC20 balances, transfers, allowances), always useu256—matching Solidity’s uint256 for crosschain compatibility.
| Type | Size | Use Case |
|---|---|---|
u64 | 64-bit | Timestamps, small counters |
u128 | 128-bit | Medium-sized values |
u256 | 256-bit | Token amounts (ERC20 balances, transfers) |
u256 for balance_of, total_supply, allowance, and all transfer/approve amounts.
You’ll also encounter
felt252 in Cairo—it’s Starknet’s base field element type used internally (e.g., ContractAddress wraps a felt252). However, don’t use it for token amounts; its modular arithmetic can cause unexpected behavior.Bytes32 for compatibility across chains with different address sizes.
Resource Bounds (Gas Model)
Starknet uses resource bounds instead of simple gas limits:Prerequisites
Before you start building, you’ll need to set up your development environment.1. Deploy and Fund an Account Contract
Unlike EVM, you need an account contract before you can deploy other contracts:Create a new account (generates keys and computes address)
Fund the computed address with STRK/ETH before deploying.
Theaccount create command outputs the computed address. Fund this address using a faucet before running account deploy.
Deploy the account contract
2. Account File Location
Accounts are stored in~/.starknet_accounts/starknet_open_zeppelin_accounts.json:
3. Install Scarb (Cairo Build Tool)
Scarb is the official Cairo package manager and build tool:4. Install Starknet Foundry (sncast + snforge)
Starknet Foundry providessncast (deployment) and snforge (testing):
5. Configure snfoundry.toml
Create asnfoundry.toml in your project root to configure sncast defaults:
| Field | Description |
|---|---|
account | Account name from your accounts file |
url | RPC endpoint URL (must match sncast version; see RPC note above) |
wait-params | Transaction wait timeout and retry settings |
block-explorer | Explorer for transaction links (StarkScan, Blockchain, Voyager) |
show-explorer-links | Show explorer links after transactions |
sncast account list to see available account names.
6. Install Node.js
For any TypeScript tooling or SDK usage:7. Get Testnet STRK/ETH
For testing on Starknet Sepolia testnet:- Starknet Faucet - Get testnet STRK
- Starkgate Bridge - Bridge ETH from Ethereum Sepolia
Project Structure
A typical LayerZero Starknet project structure:Scarb.toml:
Installing LayerZero PackagesBefore building, install the LayerZero Cairo contracts:
Network Configuration
| Network | Endpoint ID | Chain ID |
|---|---|---|
| Starknet Mainnet | 30500 | SN_MAIN |
| Starknet Sepolia | 40500 | SN_SEPOLIA |
RPC Endpoints:SN_MAINandSN_SEPOLIAare Starknet’s native chain-id identifiers, defined by the Starknet protocol to identify the target network for transactions.
- Mainnet:
<YOUR_MAINNET_RPC_URL> - Sepolia:
<YOUR_SEPOLIA_RPC_URL>
RPC providersBlast public endpoints are deprecated; use Alchemy, Infura, or another provider that supports Starknet JSON-RPC v0.9+.
Next Steps
Choose your path:Build an OApp
For custom crosschain logic:- OApp Overview - Architecture and patterns
- Protocol Overview - Deep technical dive
- Technical Overview - Starknet fundamentals
Build an OFT
For crosschain tokens:- OFT Overview - Token architecture
- Configuration Guide - Security and DVN setup
Understand the Protocol
For protocol-level understanding:- Technical Overview - Cairo architecture and patterns
- Protocol Overview - Complete message workflows
Get Help
- Troubleshooting - Common issues
- FAQ - Frequently asked questions
- Discord - Community support