Deploying to IC Mainnet
This guide walks through deploying your canisters to the Internet Computer mainnet.
Prerequisites
Before deploying to mainnet, ensure you have:
- A working project — Test locally first with
icp deployon your local network - An identity — See Managing Identities
- Cycles — Canisters require cycles to run on mainnet
Setting Up an Identity
If you haven’t already, create an identity:
icp identity new mainnet-deployerSet it as default:
icp identity default mainnet-deployerView your principal:
icp identity principalAcquiring Cycles
Canisters need cycles to operate on mainnet. You’ll need cycles before deploying.
Quick start:
# Check your cycles balanceicp cycles balance -e ic
# Convert ICP to cycles (if you have ICP)icp cycles mint --icp 1 -e icHow many cycles do you need?
- Creating a canister: ~100B cycles (0.1T)
- Simple backend: 1-5T cycles lasts weeks to months
- Start with 1-2T cycles and top up as needed
For detailed information on acquiring ICP, converting to cycles, and managing balances, see Tokens and Cycles.
Deploying
To deploy to the IC mainnet, use the implicit ic environment with the --environment ic flag or the -e ic shorthand:
icp deploy --environment icThis will:
- Build your canisters
- Create canisters on mainnet (if first deployment)
- Install your WASM code
- Run any sync steps (e.g., asset uploads)
Deploying Specific Canisters
Deploy only certain canisters:
icp deploy frontend --environment icUsing Environments
You can configure multiple environments pointing to the IC mainnet in icp.yaml:
environments: - name: prod network: ic # ic is an implicit network - name: staging network: icThis allows you to deploy independent sets of canisters for each environment:
icp deploy -e stagingicp deploy --environment prodSee Managing Environments for setup details.
Verifying Deployment
List canisters configured in this environment:
# List the canisters in an environmenticp canister list -e myenv
# Check canister status:icp canister status my-canister -e myenv
# Call a method to verify it's working:icp canister call my-canister greet '("World")' -e myenvUpdating Deployed Canisters
After making changes, redeploy:
icp deploy --environment prodThis rebuilds and upgrades your existing canisters, preserving their state.
Managing Canister Settings
View current settings:
icp canister settings show my-canister -e prodUpdate settings:
icp canister settings update my-canister --freezing-threshold 2592000 -e prodTopping Up Cycles
Monitor canister cycles and top up when needed:
# Check canister cycles balanceicp canister status my-canister -e prod
# Top up with 1 trillion cyclesicp canister top-up my-canister --amount 1000000000000 -e prodSee Tokens and Cycles for more on managing cycles.
Troubleshooting
“Insufficient cycles”
Your canister needs more cycles. Top up using:
icp canister top-up my-canister --amount 1000000000000 -e prod“Not a controller”
You’re not authorized to modify this canister. Verify you’re using the correct identity:
icp identity principalicp identity listIf needed, switch to the correct identity:
icp identity default <identity-name>Next Steps
- Tokens and Cycles — Managing ICP and cycles in detail
- Managing Environments — Set up staging and production