# Deleted a canister created by a canister, but the cycles are not refunded

**URL:** <https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750>\
**Category:** Developers\
**Created:** [April 13, 2025, 10:28am UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750 "2025-04-13T10:28:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kayicp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/kayicp/32/36679_2.png) [@kayicp](https://forum.dfinity.org/u/kayicp)\
**Post date:** [April 13, 2025, 10:28am UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/1 "2025-04-13T10:28:12Z")

</div>

after i created a canister via a canister, the new one’s balance is 500\_000\_000\_000 and it’s asking me to topup to install code on it.  
i decided to delete it and fix the canister’s code that creates the canister… but the cycles on the new one is not refunded to the creator canister.

is there a reason why? or the delete canister has a fee?

---

<div class="post-metadata">

**Author:** ![michael-weigelt](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@michael-weigelt](https://forum.dfinity.org/u/michael-weigelt)\
**Post date:** [April 14, 2025, 8:04am UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/2 "2025-04-14T08:04:51Z")

</div>

Hi there

Did you _uninstall_ your code or _delete_ your canister? In the latter case, [the cycles are lost](https://internetcomputer.org/docs/references/ic-interface-spec#ic-delete_canister).

Otherwise, you can just reinstall code on the same canister id and use the cycles. If you don’t want to use that canister id anymore, you can install a wallet canister on that canister id and transfer your cycles out.

---

<div class="post-metadata">

**Author:** ![kayicp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/kayicp/32/36679_2.png) [@kayicp](https://forum.dfinity.org/u/kayicp)\
**Post date:** [April 14, 2025, 1:45pm UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/3 "2025-04-14T13:45:59Z")

</div>

i see. it’s an expensive lesson for me then. may i know why the design is like this instead of refunding the cycle balance back the installer or controller?

also when i was done fixing the code, and try to upgrade, it keeps on throwing the error: the install code must have at least N amount. but when i topped it up, it threw the same error again but with M amount, later K amount, then J amount, and so on but i keep on topping it up… until i decide to topup 10x the amount then it resolves. it’s a bad dev experience tbh due to the misleading error " canister must have at least this amount". maybe a better approach is to specify the recommended amount for a successful upgrade.

---

<div class="post-metadata">

**Author:** ![michael-weigelt](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@michael-weigelt](https://forum.dfinity.org/u/michael-weigelt)\
**Post date:** [April 14, 2025, 2:00pm UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/4 "2025-04-14T14:00:12Z")

</div>

The installer is not known, and there may be many controllers. To which one should the cycles go? Even if there was a single controller, only canisters can hold cycles, not arbitrary principals (the system was designed way before the cycles ledger which gives the illusion that any principal can hold cycles).

DFX has a command for moving most cycles out of a no longer used canister, you may want to use that in the future. Check the DFX documentation.

I’ll forward your feedback about the “least amount of cycles” internally, thanks!

---

<div class="post-metadata">

**Author:** ![michael-weigelt](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@michael-weigelt](https://forum.dfinity.org/u/michael-weigelt)\
**Post date:** [April 14, 2025, 2:31pm UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/5 "2025-04-14T14:31:01Z")

</div>

The error response from the IC about the minimum amount of cycles is as good as it can be, but unfortunately parameters can change quickly in a few seconds. E.g., if your canister suddenly uses a bit more memory, then its freezing threshold is larger, and the amount that was correct a second ago no longer suffices. But this is not something the system can predict, so it gives a lower bound to the best of its knowledge.

---

<div class="post-metadata">

**Author:** ![DATHKA](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@DATHKA](https://forum.dfinity.org/u/DATHKA)\
**Post date:** [April 14, 2025, 4:06pm UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/6 "2025-04-14T16:06:50Z")

</div>

> [@michael-weigelt](#):
>
> DFX has a command for moving most cycles out of a no longer used canister, you may want to use that in the future. Check the DFX documentation.

Hi Michael, could you elaborate on that? I couldn’t find anything like this in the dfx documentation, other than installing the wallet canister wasm and then interacting with this to transfer out. Or is this what you were referring to?

---

<div class="post-metadata">

**Author:** ![michael-weigelt](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@michael-weigelt](https://forum.dfinity.org/u/michael-weigelt)\
**Post date:** [April 15, 2025, 7:23am UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/7 "2025-04-15T07:23:01Z")

</div>

Turns out, `dfx canister delete` does this by default: [dfx canister | Internet Computer](https://internetcomputer.org/docs/building-apps/developer-tools/dfx/dfx-canister#dfx-canister-delete)

---

<div class="post-metadata">

**Author:** ![timo](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/timo/32/5543_2.png) [@timo](https://forum.dfinity.org/u/timo)\
**Post date:** [April 15, 2025, 10:07am UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/8 "2025-04-15T10:07:57Z")

</div>

> [@kayicp](#):
>
> after i created a canister via a canister, the new one’s balance is 500\_000\_000\_000 and it’s asking me to topup to install code on it.

> [@kayicp](#):
>
> also when i was done fixing the code, and try to upgrade, it keeps on throwing the error: the install code must have at least N amount. but when i topped it up, it threw the same error again but with M amount, later K amount, then J amount, and so on but i keep on topping it up…

Can you elaborate more on these errors? Because normally only 300B + change (310B is enough) are required to be able to install code or upgrade code in a canister. Not 500B or more. Was there something special in your case, for example, did you have a very long freezing threshold set, was the wasm module to install very large, was the memory footprint of the canister very large before the upgrade, etc?

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [April 16, 2025, 11:54am UTC](https://forum.dfinity.org/t/deleted-a-canister-created-by-a-canister-but-the-cycles-are-not-refunded/43750/9 "2025-04-16T11:54:32Z")

</div>

> [@timo](#):
>
> Because normally only 300B + change (310B is enough) are required to be able to install code or upgrade code in a canister. Not 500B or more.

This assumes a 13-nodes subnet. The required amount of cycles is larger on a fiduciary subnet:

```auto
34/13 * 300B ~ 784.61B

```
