Deploying Programs
Deploying a Solana program uploads BPF bytecode to a program data account via the upgradeable loader. Use Solana CLI 3.0.10 or anchor deploy after anchor build on Agave 4.1.1 clusters.
Search across all documentation pages
Deploying a Solana program uploads BPF bytecode to a program data account via the upgradeable loader. Use Solana CLI 3.0.10 or anchor deploy after anchor build on Agave 4.1.1 clusters.
Quick-reference recipe card - copy-paste ready.
anchor build
solana program deploy target/deploy/my_program.so \
--program-id target/deploy/my_program-keypair.json \
--url devnetWhen to reach for this:
#!/usr/bin/env bash
set -euo pipefail
CLUSTER=devnet
PROGRAM_SO=target/deploy/my_program.so
PROGRAM_KEYPAIR=target/deploy/my_program-keypair.json
solana config set --url "$CLUSTER"
solana balance
# Build reproducible artifact
anchor build
# Estimate cost
solana program deploy "$PROGRAM_SO" --program-id "$PROGRAM_KEYPAIR" --dry-run
# Deploy
DEPLOY_OUT=$(solana program deploy "$PROGRAM_SO" --program-id "$PROGRAM_KEYPAIR")
echo "$DEPLOY_OUT"
PROGRAM_ID=$(solana-keygen pubkey "$PROGRAM_KEYPAIR")
solana program show "$PROGRAM_ID"What this demonstrates:
--dry-run previews rent and CU without landing.declare_id!.program show confirms authority and data length post-deploy.| Factor | Impact |
|---|---|
.so file size | Rent proportional to bytes |
| Cluster | devnet cheaper SOL; mainnet real cost |
| Failed deploy | Buffer rent until closed |
| Priority fees | Landing speed during congestion |
# Close failed buffer to reclaim rent
solana program close <BUFFER_ADDRESS>declare_id! != keypair pubkey. Fix: anchor keys sync after keygen.solana program deploy --dry-run first.solana config get before deploy.solana-verify build pipeline.| Alternative | Use When | Don't Use When |
|---|---|---|
anchor deploy | Anchor workspace | Raw native program only |
| Buffer resume | Large SO / flaky net | Tiny programs |
| Squads deploy proposal | Production governance | Solo devnet iteration |
Primarily rent for program data (~size of .so); use --dry-run for estimate on your cluster.
No - ID is keypair pubkey; changing ID is a new deployment and migration of state.
anchor build wraps cargo build-sbf and generates IDL - prefer for Anchor 0.32.1 projects.
Temporary holding account for ELF chunks during multi-step deploy.
Partial buffer remains - close buffer or resume deploy from buffer address.
Yes - deploy separately per cluster with cluster-specific program keypairs if needed.
Build in CI, deploy with secured key from secret manager, verify hash post-deploy.
Possible by revoking authority immediately - rare; usually keep authority through audit period.
Separate account from program ID - program show lists ProgramData address holding ELF.
Build with matching platform-tools so deployed ELF matches validator BPF loader expectations.
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 16, 2026