Overview
Theanchor upgrade command upgrades a single program on the Solana cluster. The configured wallet must be the upgrade authority.
Command Syntax
Migration
Instead of:Arguments
pubkey
required
The program ID to upgrade
string
required
Filepath to the new program binary (e.g.,
target/deploy/my_program.so)Options
number
default:"0"
Maximum number of times to retry on failure
string
Arguments to pass to the underlying
solana program deploy commandExamples
Basic Upgrade
Upgrade with Retries
Upgrade Verifiable Build
Pass Solana CLI Arguments
Upgrade Process
- Validates the upgrade authority has permission
- Uploads the new program binary to a buffer account
- Calls the upgrade instruction on the BPF Upgradeable Loader
- Replaces the existing program with the new binary
- Closes the buffer account and reclaims rent
Authority Requirements
The wallet specified inAnchor.toml or via the Solana CLI config must be the upgrade authority for the program. You can verify this with:
Cluster Configuration
The upgrade cluster is determined by:Failure Handling
If the upgrade fails:- Check your upgrade authority is correct
- Ensure you have enough SOL for rent and fees
- Verify the program binary is valid
- Use
--max-retriesfor network issues
Comparison with New Command
Notes
The program’s data account is preserved during an upgrade, so program state is maintained.
See Also
- anchor program upgrade - Recommended replacement
- anchor program set-upgrade-authority - Change upgrade authority
- anchor build —verifiable - Create verifiable builds