Usage
Options
Fee Options
number
Priority fee in microcredits. Higher fees may result in faster confirmation.
string
Record to use for paying the priority fee
Transaction Actions
boolean
Broadcast the upgrade transaction to the network
string
Save the upgrade transaction to the specified directory
boolean
Print the upgrade transaction in JSON format
Environment Options
string
default:"testnet"
Network to deploy to (mainnet, testnet, canary)
string
Custom API endpoint URL
string
Private key for signing (can also use PRIVATE_KEY environment variable)
Build Options
string[]
Skip upgrade of programs containing these substrings
boolean
Skip deployment certificate generation (advanced usage)
boolean
Skip confirmation prompts
Examples
Basic upgrade
Upgrade with priority fee
Save upgrade transaction without broadcasting
Skip specific programs
Upgrade to mainnet
Upgrade Requirements
Valid Upgrade Rules
- Constructor Must Exist: New version must have a constructor
- Mappings Cannot Change: Mapping definitions must remain identical
- Records Can Be Added: New record types can be added
- Function Signatures: Can modify logic but some constraints apply
- Edition Increments: Edition number automatically increments
Example Valid Constructor
Upgrade Process
1
Build updated program
Leo automatically builds your project before upgrading.
2
Verify program exists on network
The command checks that the program is already deployed.
3
Validate upgrade compatibility
Checks that the upgrade follows all rules:
- Constructor requirements
- Mapping compatibility
- Naming structure
- Consensus version compatibility
4
Generate upgrade transaction
Creates the upgrade deployment transaction with incremented edition.
5
Broadcast or save
Either broadcasts to network or saves to file.
Upgrade Validation
Before upgrading, the command validates:Program Existence
Upgrade Compatibility
Warnings
Edition System
Each upgrade increments the program’s edition number:- Key generation
- Transaction validation
- State migration
Cost Estimation
The command displays estimated costs before broadcasting:JSON Output
Enable--json-output for machine-readable results:
Consensus Versions
Different consensus versions have different upgrade rules:- V7+: Program naming structure validation
- V8+: One-time upgrades for programs without constructors
- V9+: Constructor required for all upgrades
Common Issues
Program not found on network
Invalid upgrade: mapping changed
Mapping definitions cannot be modified:Constructor missing
Add a constructor to your program:Related Commands
Best Practices
State preservation: Upgrades preserve all on-chain state including mapping values and program balance.