To upgrade/re-deploy a canister smart contract on the Internet Computer blockchain mainnet:
- Open a new terminal and navigate to your project directory.
- Start the Internet Computer network, if necessary.
In most cases, this step is only necessary if you are running the Internet Computer network locally.
If you were upgrading canisters on a remote network, you would include the --network command-line option to perform tasks on that network. - Verify you have canister identifiers for all of the canisters you want to upgrade.
Note that your program must identify the variables for which to maintain state by using the stable keyword in the variable declaration.
For more information about declaring stable variables, see the Motoko Programming Language Guide. - Upgrade all of the canisters by running the following command:
dfx canister install --all --mode upgrade
Similar steps are involved for a local upgrade:
- Open a new terminal and navigate to your project directory.
- Verify you have canister identifiers for all of the canisters you want to upgrade.
- Upgrade all of the canisters by running the following command:
dfx canister install --all --mode upgrade
To view in-depth information about upgrading and reinstalling canisters, please check out the helpful articles from the Developer Center.
You can also learn more about canisters on the Internet Computer Wiki.
Comments
0 comments
Please sign in to leave a comment.