How Solana Differs from EVM
If you’re coming from Ethereum/Solidity, Solana’s programming model is fundamentally different:| Concept | EVM (Ethereum) | Solana |
|---|---|---|
| Smart contracts | Contracts store their own state | Programs are stateless; data lives in separate accounts |
| Language | Solidity | Rust (via Anchor framework) |
| Execution | Sequential | Parallel (accounts declared upfront) |
| Fees | Gas (variable, can be expensive) | Fixed low fees (~$0.00025 per tx) |
| Finality | ~12 seconds (Ethereum L1) | ~400ms |
| Token standard | ERC-20 | SPL Token |
| Local dev | Anvil / Hardhat | solana-test-validator |
Anchor Framework
Anchor is to Solana what Hardhat/Foundry is to Ethereum — a higher-level framework that handles the boilerplate. Most production Solana apps use Anchor. Anchor gives you:- Automatic account serialization/deserialization
- Declarative account validation (constraints)
- IDL generation (like ABI for Solana)
- TypeScript client generation
- Built-in testing framework
Project Structure
An Anchor project looks like this:Setting Up the Toolchain
First time only — install Rust, Solana CLI, and Anchor:- Rust (stable toolchain)
- Solana CLI v2.3.0
- Anchor v0.32.0
Writing an Anchor Program
Here’s a minimal counter program:#[program]— defines your instruction handlers#[derive(Accounts)]— declares which accounts each instruction needs#[account]— defines the data schema for an accountContext<T>— provides access to the validated accounts
Important Version Constraints
Always use these exact versions in yourCargo.toml:
edition = "2021" in your Cargo.toml (not 2024 — Solana’s platform tools don’t support it yet).
Compiling
.sobinary — the compiled program for deployment- IDL file — describes your program’s interface (like an ABI)
- TypeScript types — generated from the IDL for client code
- Type mismatches
- Missing trait implementations
- Account constraint violations
- Wrong dependency versions
Local Development
Start a Local Validator
solana-test-validator at http://127.0.0.1:8899. You get:
- Instant transaction finality
- Unlimited SOL airdrops
- Clean state (resets when stopped)
- No rate limits
Fund Your Wallet
Deploying Programs
To Local
.so file and deploys it. You get back the program ID (the on-chain address of your program).
To Devnet/Testnet
To Mainnet
Program Upgrades
By default, the deployer retains upgrade authority — you can deploy new versions to the same program address. You can:- Upgrade the program later with new code
- Transfer upgrade authority to a multisig
- Revoke upgrade authority to make it immutable
SPL Token Operations
SPL tokens are Solana’s equivalent of ERC-20. Manage them through chat:Create a Token
Mint Tokens
Transfer Tokens
Check Balance
Program Derived Addresses (PDAs)
PDAs are deterministic addresses derived from a program ID and seeds. They’re fundamental to Solana development:- Program-controlled token accounts (programs can “sign” for PDAs)
- Deterministic data accounts (predictable addresses based on user + seed)
- Cross-program invocation authority
Solidity on Solana (Solang)
If you prefer Solidity over Rust, you can compile Solidity for Solana using Solang:- Account management requires explicit annotations
- Storage works differently (data lives in accounts, not contract storage)
- Not all Solidity features are available
- Different gas/compute model
Workflow Summary
Troubleshooting
Build fails with edition2024 error
Build fails with edition2024 error
Use
edition = "2021" in Cargo.toml and solana-program = "2.1" (not 2.2+). Solana’s platform tools don’t support Rust edition 2024 yet.Deployment fails
Deployment fails
Check: wallet connected, sufficient SOL for rent, correct network selected,
.so file exists in target/deploy/.Airdrop rate limited
Airdrop rate limited
On public devnet/testnet, wait a few minutes between requests. Request 1-2 SOL at a time. On local, there are no limits.
Account-related errors
Account-related errors
Toolchain version conflicts
Toolchain version conflicts
Use exactly:
anchor-lang = "0.32.0", solana-program = "2.1", edition = "2021". Don’t add unnecessary solana-* crates.
