Cycles not appearing in cycles ledger after successful canister deletion

Hi,

I recently deleted my cycles wallet canister and several canisters controlled by it on mainnet. The deletion output confirmed a successful withdrawal (e.g., “Successfully withdrew 19487897969873 cycles”), but my cycles ledger balance shows 0.

Details:

  • Identity principal: 2dt5i-kgxis-5kspz-ohx5f-mc4bs-5o2rv-hocv2-ujbgw-icmec-ccpoh-hae

  • Deleted wallet canister ID: lc52s-fyaaa-aaaan-qeida-cai

  • Other deleted canister IDs: kvqz3-vqaaa-aaaan-qlurq-cai
    , kaxiw-uyaaa-aaaan-qlusa-cai

  • Cycles ledger balance after deletion: dfx cycles balance --network ic
    0.000 TC (trillion cycles).

  • Cycles wallet balance: N/A (wallet was deleted)

Steps taken:

  1. Stopped and deleted canisters controlled by the wallet.

  2. Stopped and deleted the cycles wallet canister itself.

  3. Checked cycles ledger balance — shows 0 despite the confirmed withdrawal.

Could you help trace where the cycles ended up? Is there a way to recover them?

Thank you!

Thanks for the response but not sure what you mean.

When you delete a canister, its cycles likely go to the wallet canister. But you’ve deleted the wallet canister. Sounds like an edge case - likely a bug.

Could be an edge case. I had to add my principal as a controller to the wasm canisters as my wallet canister had run out of cycles. Not sure if that would be an issue or not but I deleted the canisters and the cycles were returned to the wallet successfully. I then stopped and deleted the wallet expecting the cycles to be returned to the ledger but no luck. Thanks for the response.

that’s what I am talking about, when you delete the canister, withdraws cycles to wallet canister by default but, you deleted the wallet canister, before you delete the canister either you had to migrate cycles to cycles ledger or you had to specify to which canister you would like to withdraw.

ok, that’s a step I didn’t take. I was under the impression that the cycles would be returned to the controller of the wallet canister.

oh wait, now I understand why this might me edge case, when I say those, I was thinking about past years but now when I think about it maybe they updated dfx for delete function to withdraw and deposit them to cycles ledger by default. if this is true, the conflict might be something like this; since you had both cycles wallet and cycles ledger maybe when you run delete maybe dfx first reads your local json file to find canister ID and sends the cycles there. I’m mean new versions may cycles ledger aware but as fallback to wallet check. so perhabs since there was cycles wallet in your local config, dfx sent the cycles to your wallet canister ID instead ledger, even when you delete it. in short I might be wrong in my previous messages because I assumed that delete option doesn’t withdraw to cycles ledger but they might just didn’t update the docs.

Thanks. I am no expert but I know dfx deletes the network canister ids in the local dir when the network canister is deleted. Not sure what else it does. I am actually trying to migrate to icp-cli as it seems a bit more straight forward concerning cycles management. However it would be good to know how I messed up lol.

yeah but when you were trying to delete wallet canister, that wallet canister was still exist lol so probably dfx first read the wallet canister ID and did not fallback to migrate cycles ledger automatically since there was wallet canister there.

that sounds like a bug then. All I know is this from terminal:
Successfully withdrew 19487897969873 cycles.
Deleting canister lc52s-fyaaa-aaaan-qeida-cai, with canister_id lc52s-fyaaa-aaaan-qeida-cai

can you share your exact command to delete wallet canister

dfx canister delete $(dfx identity get-wallet --ic) --network ic

is it possible you may deployed second wallet? you can check with dfx identity get-wallet –ic

yes it returns the wallet id. It shouldn’t do that right?

is this wallet id different? if it’s you definitely have another wallet lol. check the balance.

no the id is the same as before. lc52s-fyaaa-aaaan-qeida-cai

dfx wallet --network=ic balance  :check_mark:
Error: Failed to setup wallet caller.
Caused by: Failed to construct wallet canister caller
Caused by: The replica returned a rejection error: reject code DestinationInvalid, reject message Canister lc52s-fyaaa-aaaan-qeida
-cai not found, error code Some("IC0301")

@uwxsgs is pretty much right with their assumptions. There is no automated way to switch between cycles wallet and cycles ledger. The manual steps listed here are the only way.

What happened is that first dfx checks if a wallet is configured. Since there is one, it will withdraw cycles to said wallet, and then delete the target canister. Since the wallet is the target, this essentially performed --non-withdrawal. The cycles are gone

That makes sense now. I forgot to make the deposit call after deleting the network canisters. Presumably then the wallet would have the cycles from the deleted canisters and I would be able to make the “deposit” call without it telling me that the wallet was out of cycles.

Thanks!