Building & Deploying
Build compiles your program to SBF and regenerates the IDL. Deploy uploads the .so to a cluster and updates the program ID mapping in Anchor.toml.
Search across all documentation pages
Build compiles your program to SBF and regenerates the IDL. Deploy uploads the .so to a cluster and updates the program ID mapping in Anchor.toml.
anchor build
anchor deploy --provider.cluster devnet
anchor keys syncWhen to reach for this: You ship a new version or onboard a fresh program ID.
# Verify toolchain
anchor --version # 0.32.1
solana --version # solana-cli 3.0.10
# Build SBF + IDL
anchor build
# Deploy to devnet (funded wallet)
anchor deploy --provider.cluster devnet
# Sync declare_id! and Anchor.toml from deployed keypair
anchor keys sync
# Confirm on-chain program
solana program show <PROGRAM_ID> --url devnet# programs/my_program/Cargo.toml
[dependencies]
anchor-lang = "0.32.1"
anchor-spl = "0.32.1"What this demonstrates:
target/deploy/*.so is the upgradeable program binarytarget/idl/<name>.json drives client codegenanchor keys sync aligns declare_id! with keypairAnchor.toml or CLI flagscargo build-sbf compiles Rust to Solana BPF.| Step | Command |
|---|---|
| Fund deployer | solana airdrop 2 (devnet) |
| Build | anchor build |
| Deploy | anchor deploy |
| Sync IDs | anchor keys sync |
| Verify | solana program show |
anchor build before deploy.[provider] cluster in Anchor.toml.| Alternative | Use When | Don't Use When |
|---|---|---|
| solana program deploy | Non-Anchor workflows | You lose IDL generation step |
| CI verifiable builds | Audited releases | Local quick iteration |
| Surfpool for local only | No cluster spend | Final deploy still needs cluster |
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 build deploy 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