25T cycles lost when deleting canister

Execution command and error are as follows:

dfx cycles balance --ic
Please enter the passphrase for your identity: [hidden]
Decryption complete.
0.316 TC (trillion cycles).
dfx canister delete --withdraw-cycles-to-dank delta --ic
Please enter the passphrase for your identity: [hidden]
Decryption complete.
Beginning withdrawal of cycles; on failure try --no-wallet --no-withdrawal.
WARNING!
Canister delta has not been stopped. Delete anyway?
Do you want to proceed? yes/No
yes
Setting the controller to identity principal.
Installing temporary wallet in canister delta to enable transfer of cycles.
Attempting to transfer 25314065070620 cycles to dank principal bnjq6-7vpf2-o4slv-whuhw-dx4pg-bdtfd-efseq-fkctz-tn2vr-ogxnm-2qe.
Not enough margin. Trying again with more margin.
Attempting to transfer 25311065070620 cycles to dank principal bnjq6-7vpf2-o4slv-whuhw-dx4pg-bdtfd-efseq-fkctz-tn2vr-ogxnm-2qe.
Not enough margin. Trying again with more margin.
Attempting to transfer 25275065070620 cycles to dank principal bnjq6-7vpf2-o4slv-whuhw-dx4pg-bdtfd-efseq-fkctz-tn2vr-ogxnm-2qe.
Not enough margin. Trying again with more margin.
Attempting to transfer 25272065070620 cycles to dank principal bnjq6-7vpf2-o4slv-whuhw-dx4pg-bdtfd-efseq-fkctz-tn2vr-ogxnm-2qe.
Not enough margin. Trying again with more margin.
Attempting to transfer 25269065070620 cycles to dank principal bnjq6-7vpf2-o4slv-whuhw-dx4pg-bdtfd-efseq-fkctz-tn2vr-ogxnm-2qe.
Not enough margin. Trying again with more margin.
Attempting to transfer 25266065070620 cycles to dank principal bnjq6-7vpf2-o4slv-whuhw-dx4pg-bdtfd-efseq-fkctz-tn2vr-ogxnm-2qe.
Not enough margin. Trying again with more margin.
Attempting to transfer 25263065070620 cycles to dank principal bnjq6-7vpf2-o4slv-whuhw-dx4pg-bdtfd-efseq-fkctz-tn2vr-ogxnm-2qe.
Not enough margin. Trying again with more margin.
Attempting to transfer 25260065070620 cycles to dank principal bnjq6-7vpf2-o4slv-whuhw-dx4pg-bdtfd-efseq-fkctz-tn2vr-ogxnm-2qe.
Error: Failed to delete canister 'delta'.
Caused by: Failed mint call.
Caused by: The invocation to the wallet call forward method failed with the error: An error happened during the call: 5: IC0503: Error from Canister aanaa-xaaaa-aaaah-aaeiq-cai: Canister called `ic0.trap` with message: Custom(Fail to decode argument 0 from table0 to principal

Caused by:
    0: input: 4449444c016e680100_01011daf2e9dc92eb63d0f61df8f3047328c859120550a799b7558b8d76b3502
       table: type table0 = opt principal
       wire_type: table0, expect_type: principal
    1: table0 is not a subtype of principal
    2: opt principal is not a subtype of principal).
Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly

The deletion was successful, but the cycles were not recovered successfully. Can these cycles be recovered?

It seems that canister has not been deleted and has been stopped, but I don’t know how to delete and reclaim the cycles balance.

Failed mint call. means that depositing the cycles to dank.ooo failed. The canister still holds yoru cycles and has not been deleted. To me it looks like --withdraw-cycles-to-dank is broken. If you simply skip that flag the cycles should be to your cycles wallet (if you have one) or the cycles ledger under your principal’s account

Do you mean to remove the --withdraw-cycles-to-dank args and directly dfx canister delete delta --ic, and the cycles will be returned to the wallet?
Because I am not sure what args need to be added to return the balance to dfx cycles balance --ic

If you use dfx cycles balance then you want the cycles to be returned to the cycles ledger.
If you use dfx wallet balance then you want the cycles to be returned to the cycles wallet.

dfx canister delete will automatically return the cycles to

  • the cycles wallet if a cycles wallet is configured
    • A cycles wallet is configured if dfx identity wallet balance --ic does not return an error
  • the cycles ledger if no wallet is configured
1 Like