Anchor vs Pinocchio

Sunscreen supports two Solana program frameworks. Choose based on what you're optimizing for.

TL;DR

AnchorPinocchio
Mental modelHigh-level, macros do the heavy liftingLow-level, you wire account checks yourself
Compile-time guaranteesStrong (#[derive(Accounts)] checks at build time)Minimal (you assert at runtime)
Compute unitsHigher overheadNear-bare-metal
Code volumeLess code per instructionMore code per instruction
Sunscreen supportFull (scaffold, codegen, recipes, plugins)Workspace bootstrap + build only
When to pickNew projects, productivity-firstPerformance-critical paths, audit-sensitive code

Anchor in one paragraph

Anchor is a Rust framework on top of the Solana program SDK. It defines three macros (#[program], #[derive(Accounts)], #[account]) that hide most of the account-handling boilerplate. It also auto-generates an IDL, which sunscreen feeds into Codama for client generation. Default choice for productivity.

Pinocchio in one paragraph

Pinocchio is a thin, no-allocation alternative for Solana programs. It exposes the runtime more directly, so you pay fewer compute units (CUs) per instruction. There's no IDL emission, no codegen, no Anchor macros — you write the dispatch and account validation by hand. Use for programs where CU budget matters.

Sunscreen's coverage today

FeatureAnchorPinocchio
chain new✅ (minimal template)
chain build✅ (cargo build-sbf)
chain serve
scaffold instruction/account/event/error❌ (manual)
scaffold crud/spl-token/metaplex-nft
generate idl❌ (no IDL)
generate clients
generate frontend-hooks
Plugin scaffold <noun>partial (plugins decide)

If you choose Pinocchio, sunscreen still gives you the workspace bootstrap, build, and local dev loop. Scaffolders and codegen require Anchor's IDL.

Migrating between

There's no automatic migration. Anchor programs use macros and account layouts that don't map 1:1 to Pinocchio. If you want to migrate a hot path to Pinocchio, the typical pattern is:

  1. Keep the Anchor program as the user-facing surface.
  2. Extract the hot instruction into a separate Pinocchio program.
  3. Have the Anchor program CPI into the Pinocchio program.

See also