Note that this guide uses dfx version 0.8.1
- Create a new identity using
dfx identity new move_cycles
- Use the identity created by issuing
dfx identity use move_cycles
- Save the principal ID of the
move_cycles
identity to the environment variableMOVE_CYCLES_IDENTITY
by running
MOVE_CYCLES_IDENTITY=$(dfx identity get-principal)
- Use the previous identity that is controller of the wallet canister that controls the abandoned canister by issuing the following command and substituting
<your_old_identity>
accordingly
dfx identity use <your_old_identity>
- Make the
move_cycles
identity the controller of the abandoned canister.
Make sure you run this command from within a dfx project folder and edit thecanister_ids.json
file so that the canister id of the abandoned canister is present. If yourcanister_ids.json
file contains those entries,
{
"assets": {
"ic": "kwflp-viaaa-aaaae-aaaaa-cai"
},
"kanban": {
"ic": "kren3-yqaaa-aaaae-aaaaa-cai"
}
}
replace one of the canister ids with the id of the abandoned canister like this
{
"assets": {
"ic": "<abandoned_canister_id>"
},
"kanban": {
"ic": "kren3-yqaaa-aaaae-aaaaa-cai"
}
}
Then run
dfx canister --network ic update-settings --controller $MOVE_CYCLES_IDENTITY <abandoned_canister_id>
- Now that the
move_cycles
identity is the controller of the abandoned canister, switch back to it by issuing
dfx identity use move_cycles
- Run the following command to uninstall the canister
dfx canister --network ic --no-wallet uninstall-code <abandoned_canister_id>
- Now run the following command to deploy a cycles wallet to the now empty canister
dfx identity --network ic deploy-wallet <abandoned_canister_id>
- Finally you can either send cycles to the cycles wallet of your main identity by issuing the following command or accesing the cycles wallet frontend under
<abandoned_canister_id>.ic0.app
and following the instructions on screen
dfx wallet --network ic send <main_cycles_wallet_id> <amount_of_cycles_to_send>
- If you want to you can now stop the wallet canister after you moved the cycles by running
dfx canister --network ic stop <abandoned_canister_id>
and
dfx canister --network ic delete <abandoned_canister_id>
- If you no longer need the
move_cycles
identity you can also remove it by issuing
dfx idenity remove move_cycles