Anchor vs Native
Native Solana programs use entrypoint! and manual account parsing. Anchor generates dispatch, discriminators, account validation, and IDL from macros at the cost of binary size and some CU overhead.
Search across all documentation pages
Native Solana programs use entrypoint! and manual account parsing. Anchor generates dispatch, discriminators, account validation, and IDL from macros at the cost of binary size and some CU overhead.
| Concern | Native | Anchor 0.32.1 |
|---|---|---|
| Entrypoint | Hand-written | Generated by #[program] |
| Account checks | Manual in handler | #[derive(Accounts)] constraints |
| Client types | Hand-maintained | IDL / declare_program! |
| Errors | Custom u32 codes | #[error_code] + IDL mapping |
When to reach for this: You choose a framework for a new program or debate migrating existing native code.
// Anchor: validation is declarative
#[derive(Accounts)]
pub struct Increment<'info> {
#[account(mut, has_one = authority)]
pub counter: Account<'info, Counter>,
pub authority: Signer<'info>,
}
// Native equivalent: manual checks in every handler
// - verify signer
// - verify owner == program_id
// - verify counter.authority == authority.key()
// - deserialize with discriminatorWhat this demonstrates:
declare_program! CPI modules in 0.32anchor-spl and declare_program!.constraint and require!. Fix: Model threats explicitly.solana program log and CU meters.| Alternative | Use When | Don't Use When |
|---|---|---|
| Pinocchio + manual layout | CU-sensitive code | You want Anchor account macros |
| Steel framework | Structured native patterns | You need Anchor ecosystem IDL tooling |
| Stay native | Tiny program, no client codegen | Rich account validation needs |
0.32.1 for anchor-lang, Anchor CLI, and examples in this section.
Yes. Solana CLI 3.0.10 handles keypairs, airdrops, and solana program inspection.
target/idl/<program>.json in your workspace.
Yes, but every unchecked field needs explicit constraints or handler checks.
Use anchor test with Surfpool 0.12.0 or LiteSVM 0.6.x in CI.
Anchor account discriminator; do not strip it when sizing space.
Yes, or publish on-chain IDL so clients have a canonical source.
Run with logs; Anchor prints constraint name and account index.
Yes. This stack targets Agave validators with Solana CLI 3.0.10.
See sibling articles linked in Related for deeper anchor vs native topics.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 19, 2026