Project Structure
An Anchor workspace separates on-chain programs, client tests, and deployment config. Knowing where each artifact lives prevents IDL drift and broken deploy scripts.
Search across all documentation pages
An Anchor workspace separates on-chain programs, client tests, and deployment config. Knowing where each artifact lives prevents IDL drift and broken deploy scripts.
my_workspace/
Anchor.toml # cluster, scripts, program IDs
Cargo.toml # workspace root
programs/
my_program/
Cargo.toml # anchor-lang = "0.32.1"
src/lib.rs
tests/
my_program.ts
target/
deploy/ # .so after build
idl/ # JSON IDLWhen to reach for this: You are onboarding to an existing repo or splitting one program into multiple crates.
# Anchor.toml (excerpt)
[toolchain]
anchor_version = "0.32.1"
[programs.localnet]
my_program = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"# Cargo.toml (workspace root)
[workspace]
members = ["programs/*"]
resolver = "2"What this demonstrates:
Anchor.toml is the single source for program IDs per clusterprograms/target/idl/ is generated; do not hand-edit| Path | Purpose |
|---|---|
programs/*/src/lib.rs | On-chain logic |
Anchor.toml | Deploy targets and test scripts |
target/idl/*.json | Client codegen input |
target/deploy/*.so | Upgradeable program binary |
anchor build only.declare_id!. Fix: Run anchor keys sync after deploy.anchor test cannot find them. Fix: Keep tests under tests/ per Anchor convention.Cargo.toml members.anchor-lang, and anchor-spl on 0.32.1.| Alternative | Use When | Don't Use When |
|---|---|---|
| Monorepo with multiple Anchor workspaces | Independent products sharing infra | Single program with simple layout |
| Native Cargo workspace without Anchor.toml | Maximum control, no IDL | You want typed clients and constraints |
| Pinocchio/Steel layout | CU-critical programs | You need Anchor account macros |
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 project structure 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