Can't install canister in Motoko: created canister is out of cycles

After I upgraded my dfx to 14.0, when I try to create canister with system Lib. #new (Language quick reference | Internet Computer) I get the error that the (freshly created, but not installed) canister is out of cycles:

Canister installation failed with `Canister b77ix-eeaaa-aaaaa-qaada-cai is out of cycles: requested 6_153_891_538 cycles but the available balance is 2_307_692_308 cycles and the freezing threshold 0 cycles

According to the doc:

“On the Internet Computer, calls to Lib. and (system Lib.)(#new …) must be provisioned with enough cycles for the creation of a new principal. Other call variants will use the cycles of the already allocated principal or actor.”

How am I supposed to provision the cycles ? Cause the canister that perform the motoko call has enough cycles. So far I tried (without success):

  • to add the required cycles with ExperimentalCycles.add(amount) just before calling the creation of the canister (Lib. #new)
  • to call the function that creates the canister --with-cycles amount

Thanks for letting us know.

Folks passed this to the SDK team to look into this case.

2 Likes

I’ll take a look.

In the meantime, could you share your code or a snippet and confirm you aren’t trying this in the playground but on a local or remote replica? The playground disables cycle transfers but does something else to support actor classes.

1 Like

These should both work. Form the error message I would guess that you created the canister with very few cycles. You probably created it with 0.105T cycles, from which 0.1T get deducted for canister creation, leaving you with 0.01T cycles, which is too little to do anything substantial with a canister. If you top it up with ~0.1T cycles you should be able to install wasm

1 Like

OK my bad, I think I wasn’t careful enough because this morning it’s working flawlessly… Indeed it requires 0.008T for creation and 0.006T for installation, where I think I was just adding 0.01T :clown_face:

Next time I’ll sleep on it before posting :sweat_smile: Thank you guys.

1 Like

Cool,
For the record, I adapted the actor class example to use an explicit call

Map.mo

...
//      let b = await Buckets.Bucket(n, i); // dynamically install a new Bucket
        let b =
          await
          (system Buckets.Bucket)
            (#new {settings = null})
            (n, i); // dynamically install a new Bucket
...

and it seems to work fine either way using dfx 0.14.0 (local replica)

2 Likes