Problen with cycles.add() before creating canister

Good morning… I’m having a problem when I want to create a canister from another canister, I think it’s with the issue of sending cyclos to carry out the installation and deployment of the canister. If I understand the error correctly, it would tell me that the funds available in the “Factory” canister (yucnr-hyaaa-aaaak-qcjwa-cai) however the dfx canister status command tells me that it has Balance: 7_155_117_616_330 Cycles. At first, in the line prior to creating the canister "Cycles.add(113_846_199_230); " I had it set to 13_846_199_230, and then I added 100 more because the error indicated that 100_000_000_000 were needed. I already deleted all the wasm and the files that are generated when doing the build just in case and I did deploy again but it’s still the same :confused: any ideas? I leave the repository here https://github.com/ArielRobotti/MotokoPetChain/blob/master/src/PetChain_backend/main.mo#L41-L51

I will expand the information a little about it. Indeed, every time I execute the newVet() function from the CLI, the Cycles.add(113_846_199_230) line is executed, and I checked this by checking the balance before and after executing the function. Apparently the canister is also created with its corresponding Principal, only that the canister is empty (I suppose due to the error) and I am not able to save the Principal in my array. I’m noticing that my main canister now has a looooong of Canisters that it’s a controller for, but I haven’t saved the Principals of those canisters. On the one hand, I have the doubt raised initially and now I would like to know if there is any way to recover the Principals of all the canisters of which my main canister is the controller. I must mention that all this works perfectly on my local Replica. Regarding the Cycles.add() line, in my attempt to make it work on Mainnet I tried with
import Internal "mo:⛔";
and then
Internal.cyclesAdd(113_846_199_230);
and got the same results.Thanks in advance

You should provide more than the minimum amount of Cycles needed to create a canister, otherwise the Canister gets created but immediately runs out of cycles and gets deleted.

1 Like