Deploying to IC Mainnet
This guide walks through deploying your canisters to the Internet Computer mainnet.
Understanding Mainnet Deployment
Unlike local development (which has unlimited resources), deploying to mainnet requires paying for computation and storage.
Key concepts:
-
Identity — Your cryptographic identity on the Internet Computer
- Represented by a principal (a unique identifier like
aaaaa-aa) - Think of it like your public address for receiving tokens
- Your identity will be the controller (owner) of your canisters, allowing you to deploy, update, and manage them
- Represented by a principal (a unique identifier like
-
ICP tokens — The Internet Computer’s governance token
- Purchase from cryptocurrency exchanges or receive from others
- You’ll convert ICP to cycles to power your canisters
-
Cycles — Computational fuel that powers canisters
- Canisters consume cycles for compute and storage (similar to cloud hosting costs)
- Convert ICP to cycles before deploying
Network flags you’ll see:
-n ic= network flag for token and cycles operations (e.g.,icp token balance -n ic,icp cycles mint -n ic)-e ic= environment flag for deployment and canister operations (e.g.,icp deploy -e ic,icp canister status -e ic)
Important: When working with your project’s canisters by name (like my-canister), you must use -e. The -n flag only works with canister IDs (like ryjl3-tyaaa-aaaaa-aaaba-cai).
Amount format: Amounts use human-readable suffixes throughout:
T= trillion (1,000,000,000,000)m= million,b= billion,k= thousand- Examples:
5T= 5 trillion cycles,0.5= half an ICP token
Prerequisites
Before deploying to mainnet, ensure you have:
- A working project — Test locally first with
icp deployon your local network - An identity — You’ll create one in this guide
- ICP tokens — You’ll acquire these in this guide
The following sections walk through each step. For experienced users, see the Complete Mainnet Workflow at the end.
Setting Up an Identity
Create an identity for mainnet deployments. This generates a cryptographic key pair that represents you on the Internet Computer.
icp identity new mainnet-deployer⚠️ IMPORTANT: Save the seed phrase displayed — it’s shown only once and is required to restore your identity. Store it securely offline. Without it, you’ll permanently lose access to your identity and any ICP/cycles associated with it.
Set it as default:
icp identity default mainnet-deployerView your principal (your unique identifier for receiving tokens):
icp identity principal# Output: xxxxx-xxxxx-xxxxx-xxxxx-xxx (your principal)Save this principal — you’ll need it to receive ICP tokens.
Acquiring Cycles
Now you need to get ICP tokens and convert them to cycles.
Getting ICP
To get ICP tokens (choose one method):
-
Purchase ICP — Buy ICP through cryptocurrency exchanges or wallets that support direct purchases (like OISY)
- Use your principal when withdrawing or receiving ICP
Note: Some cryptocurrency exchanges may not support principals yet. If your exchange requires an account identifier instead, use:
icp identity account-id -
Receive from another user — Share your principal with the sender:
icp identity principal
Verify ICP arrived:
icp token balance -n icRecommended starting amount: 5-10 ICP for your first deployment (converts to ~5-10T cycles).
Converting ICP to Cycles
Convert your ICP tokens to cycles (remember: “T” = trillion):
# Convert 5 ICP to cyclesicp cycles mint --icp 5 -n ic
# Or request a specific amount of cycles (ICP calculated automatically)icp cycles mint --cycles 5T -n icVerify your cycles balance:
icp cycles balance -n ic# Output: ~5T cycles (5 trillion cycles)Budget guidance: Budget 1-2T cycles per canister minimum for initial deployment.
For detailed command reference and advanced options, 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 my-canister --environment icVerifying Deployment
Check your deployment:
# List deployed canistersicp canister list -e ic
# Check canister statusicp canister status my-canister -e ic
# Call a method to verify it's workingicp canister call my-canister greet '("World")' -e icUpdating Deployed Canisters
After making changes, redeploy:
icp deploy -e icThis rebuilds and upgrades your existing canisters, preserving their state.
Managing Canisters
This section covers advanced canister management tasks.
Updating Settings
Canister settings control operational parameters like freezing threshold (how long a canister can run without cycles before freezing) and memory allocation.
View current settings:
icp canister settings show my-canister -e icUpdate settings (example shows setting freezing threshold to 30 days):
icp canister settings update my-canister --freezing-threshold 2592000 -e icSee Canister Settings for all available settings.
Managing Controllers
Controllers are principals authorized to manage a canister (deploy code, update settings, delete the canister). By default, your identity is the only controller.
Add another controller (useful for team access or backup):
icp canister settings update my-canister --add-controller <principal> -e icRemove a controller:
icp canister settings update my-canister --remove-controller <principal> -e icTopping Up Cycles
Canisters consume cycles continuously for compute and storage. Monitor cycles regularly to prevent your canister from freezing.
Check canister cycles balance:
icp canister status my-canister -e icTop up with cycles when running low:
icp canister top-up my-canister --amount 1T -e icSee Tokens and Cycles for more on managing cycles.
Using Multiple Environments
For more complex workflows with staging and production environments, you can configure multiple environments in icp.yaml:
environments: - name: staging network: ic - name: prod network: icThen deploy to each environment:
icp deploy -e stagingicp deploy -e prodSee Managing Environments for complete setup and best practices.
Complete Mainnet Workflow
Here’s the complete workflow for quick reference:
# 1. Create a dedicated mainnet identityicp identity new mainnet-deployericp identity default mainnet-deployer
# 2. Get your principal (your unique identifier) to receive ICP tokensicp identity principal# Output example: xxxxx-xxxxx-xxxxx-xxxxx-xxx# Share this principal with the sender (exchange or another user)# Note: If your exchange requires an account identifier instead, use: icp identity account-id
# 3. Verify ICP arrivedicp token balance -n ic# Output: 10 ICP
# 4. Convert ICP to cyclesicp cycles mint --icp 5 -n ic
# 5. Verify your cycles balanceicp cycles balance -n ic# Output: ~5T cycles
# 6. Deploy your project to mainneticp deploy -e ic
# 7. Monitor your canister's cyclesicp canister status my-canister -e ic
# 8. Top up if neededicp canister top-up my-canister --amount 2T -e icThe sections above explain each step in detail.
Troubleshooting
“Insufficient cycles”
Your canister needs more cycles. Top up using:
icp canister top-up my-canister --amount 1T -e ic“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
- Deploying to Specific Subnets — Target European or specialized subnets
- Managing Environments — Set up staging and production