If you want to permanently delete a specific canister smart contract or all canisters for a specific project on the Internet Computer blockchain mainnet, you can do so by running the
dfx canister delete command.
Deleting a canister removes the canister identifier, code, and state from the Internet Computer network. Before you can delete a canister, you must first stop the canister to clear any pending message requests or replies.
To delete all canisters for a project running on the local Internet Computer network:
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 deleting canisters on a remote network, you would include the
--networkcommand-line option to perform tasks on that network.
Check the status of the project canisters running on the local Internet Computer network by running the following command:
dfx canister status --all
Stop all of the project canisters by running the following command:
dfx canister stop --all
Then delete all of the project canisters by running the following command:
dfx canister delete --all