Everything You Need to Write Code on Solana
Solana is a public blockchain where anyone can deploy special-purpose programs (smart contracts) that hold and move money, and "writing code on Solana" means building those programs. To do it you need Rust, the Solana CLI (Agave), the Anchor framework, a fast local test harness, and a security toolkit built for Solana, not Ethereum. This post explains what Solana is, then walks through each tool.
What is Solana?
Solana is a blockchain: a shared database run by thousands of independent computers (validators) around the world, with no company in charge. Nobody can quietly edit its records, and anyone can read them or add to them by paying a small fee.
It launched in 2020, founded by Anatoly Yakovenko, and its native currency is SOL. Fees are paid in SOL, and validators stake SOL to earn the right to process transactions.
What sets Solana apart is speed and cost. Ethereum, the best-known programmable blockchain, processes transactions largely one after another; Solana is designed to process many in parallel. Transactions confirm in well under a second and usually cost a fraction of a cent. That makes Solana popular for trading, payments, and apps where users make many small transactions.
What "writing code on Solana" means
On a regular website, the code runs on a server the owner controls. On Solana, the code runs on the blockchain itself, and nobody, not even its author, can secretly change how it behaves.
That code is called a program (Ethereum calls the same idea a "smart contract"). A program is a set of rules that every validator runs identically. Examples:
- A token: "this account holds 100 coins; only its owner can send them."
- An exchange: "swap token A for token B at the current pool price."
- An escrow: "release the payment only when both sides have signed."
These are not ordinary apps. A Solana program can't browse the web, read files, show a screen or run on a timer. It runs only when a transaction calls it, gets a strict compute budget per call, and must give the same result on every validator. In practice it does one job: read and update account data according to its rules.
Writing code on Solana usually means two things:
- The on-chain program, written in Rust. It is compiled and uploaded to the blockchain, where it lives at a fixed address. It handles the money and enforces the rules.
- The client, usually a website or app written in TypeScript. It shows the user buttons and balances, then asks their wallet to sign transactions that call the program.
The stakes are what make it different from normal software. A program often holds real money, its code is public, and attackers can call it directly. A bug is not a crash; it is a theft. That is why testing and security tools take up so much of this guide.
Why Solana feels different
If you come from Ethereum, three things change at once:
- Programs, not contracts. On Solana, on-chain code is called a program, and it is stateless. All data lives in separate accounts that are passed into each instruction.
- Rust, not Solidity. Programs compile from Rust to sBPF bytecode and run in the Solana Virtual Machine (SVM).
- Explicit accounts. Every transaction lists up front which accounts it reads and writes. That is what lets Solana run transactions in parallel, and it is also where most Solana bugs hide: missing signer checks, unchecked account owners, and spoofed Program Derived Addresses (PDAs).
That last point matters for tooling. Ethereum security tools assume Solidity and the EVM, so most of them simply do not apply to Solana. More on that below.
Languages and frameworks
Most new programs are written in Rust with Anchor; Pinocchio is the choice when every compute unit counts.
| Layer | Tool | What it does |
|---|---|---|
| Program framework | Anchor | The standard framework. Macros handle account validation, serialization and IDL generation. Version 1.0 shipped in April 2026; the Rust crate is still anchor-lang. |
| Program framework | Pinocchio | Zero-dependency library for native programs. Lower compute cost and full control, but no built-in IDL. |
| IDL and client codegen | Codama (with Shank for Pinocchio) | Generates typed TypeScript and Rust clients from a program's IDL. |
| TypeScript client | @solana/kit | The modern JavaScript SDK for building transactions and calling programs. Replaces the older @solana/web3.js 1.x for new work. |
| Python client | solana-py / solders | Python SDK; solders provides the core types. |
If you are new, start with Anchor. It removes a whole class of account-validation bugs and gives you an IDL for free.
Setting up your machine
You need four things installed: Rust, the Solana CLI, Anchor, and a local validator. The Solana Foundation publishes a one-line installer that sets up all of them; the steps below are the manual route. Windows users should work inside WSL.
- Rust, using rustup. rustup is Rust's official installer. Run
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh(or the Windows installer from rust-lang.org) and you get two things:rustc, the Rust compiler, and Cargo, Rust's build tool and package manager. You need both: Anchor installs throughcargo install, and Solana programs are compiled withcargo build-sbf, a Cargo command the Solana CLI adds in the next step. rustup also keeps Rust updated (rustup update). Check withcargo --version. - Solana CLI (Agave). Agave is Anza's validator client, formerly the Solana Labs client, but the command is still
solana. Check withsolana --versionand upgrade withagave-install update. - Anchor through the Anchor Version Manager:
cargo install --git https://github.com/solana-foundation/anchor avm --forceavm install latest, thenanchor --version
- Surfpool, the newer replacement for
solana-test-validator. Anchor 1.0 uses it by default foranchor testandanchor localnet. - A wallet keypair:
solana-keygen new, thensolana config set --url devnetandsolana airdrop 2to get free devnet SOL.
From there, anchor init my_program gives you a working project with a program, tests and a TypeScript client.
Testing
Solana testing is a three-layer stack: Mollusk for single instructions, LiteSVM for full program flows, and Surfpool for integration tests against realistic network state.
| Layer | Tool | Use it for |
|---|---|---|
| Single instruction | Mollusk (Anza) | Pure instruction logic, compute-unit benchmarking, fixture-based regression tests. |
| Multi-instruction | LiteSVM | Runs a Solana VM inside your test process. Fast, with full bank state, sysvars and cross-program calls. Works from Rust, TypeScript and Python. |
| Integration | Surfpool | A local network that can mirror mainnet accounts, for end-to-end and client tests. |
Two older tools you will see in tutorials: solana-program-test still works but LiteSVM is its successor for new projects, and solana-bankrun has been deprecated by its own author in favor of LiteSVM (source).
Security tools: what you can and can't borrow from Ethereum
Slither, Echidna, Halmos and Foundry are excellent, but they are Ethereum (EVM) tools and do not run on Solana programs. They read Solidity or EVM bytecode; Solana programs are Rust compiled to sBPF.
What each one is, and its closest Solana counterpart:
| EVM tool | What it is | Solana counterpart |
|---|---|---|
| Slither | Trail of Bits' static analyzer for Solidity and Vyper, written in Python, with 90+ built-in vulnerability detectors. Usually the first tool wired into CI. | cargo clippy plus Anchor's account constraints; commercial Solana scanners and audit firms fill the gap. |
| Echidna | Trail of Bits' property-based fuzzer. You write invariants ("total supply never exceeds X") and it hunts for inputs that break them. | Trident by Ackee Blockchain: stateful, guided fuzzing for Solana programs, backed by the Solana Foundation. |
| Halmos | a16z's symbolic testing tool. It reuses Foundry-style tests but checks them over all possible inputs, a step toward formal verification. | No mainstream equivalent yet; property tests in Trident and careful audits cover most of this ground. |
| Foundry | The leading Solidity dev framework: forge (build and test, with built-in fuzzing), cast (chain CLI), anvil (local node) and chisel (REPL). | Anchor + Solana CLI + LiteSVM/Surfpool together play the same role. |
On Solana, the bugs that matter most are account bugs: a missing signer check, a missing owner check, an unvalidated PDA, or an unchecked arithmetic overflow. Anchor's constraint macros prevent many of these by default, which is a strong reason to start with it. Fuzz anything that holds funds with Trident, and get an independent audit before mainnet.
Deploying and verifying
Deploy to devnet first, then publish a verified build so anyone can confirm your on-chain program matches your public source.
- Deploy:
anchor deployorsolana program deploy target/deploy/<name>.so. - Verified build: install the Solana Verify CLI (
cargo install solana-verify --locked), build inside Docker withsolana-verify build, deploy that exact binary, then runsolana-verify verify-from-repoagainst your GitHub repository. Don't rebuild withanchor buildin between, or the hashes won't match. - Upgrade authority: decide who can upgrade the program. A multisig or governance program is safer than a single hot key.
A verified build proves the source matches the deployed code. It does not prove the code is safe.
Your starter checklist
- Install Rust, Solana CLI (Agave), Anchor via AVM, and Surfpool
- Create a keypair and get devnet SOL
anchor inita project and read the generated program- Learn the account model: accounts, PDAs, cross-program invocations, rent
- Write unit tests in LiteSVM or Mollusk
- Fuzz anything that holds value with Trident
- Deploy to devnet, then publish a verified build
- Get an audit before mainnet
Best places to keep learning: the official Solana docs, the Anchor book, and the Solana Foundation's program templates.