When I try to place multiple canisters on the main net, I get an error (insufficient cycles) no matter how many initial cycles I add

Hello!

I am trying to deploy multiple canisters on my mainnet.
The first canister I run deployed fine, but after the second, I always get an error.

[ first canister ]

dfx deploy GoldDIP20 --argument='("Token Gold Logo", "Token Silver", "TGLD", 8, 10000000000000000, principal '\"$ROOT_PRINCIPAL\"', 0)'  --network ic --with-cycles 1000000000000
Deploying: GoldDIP20
All canisters have already been created.
Building canisters...
Installing canisters...
Installing code for canister GoldDIP20, with canister ID hksm4-biaaa-aaaap-qauba-cai
Deployed canisters.
URLs:
  Backend canister via Candid interface:
    GoldDIP20: https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=hksm4-biaaa-aaaap-qauba-cai

[ second canister ]

dfx deploy SilverDIP20 --argument='("Token Silver Logo", "Token Silver", "TSLV", 8, 10000000000000000, principal '\"$ROOT_PRINCIPAL\"', 0)'  --network ic --with-cycles 1000000000000
Deploying: SilverDIP20
All canisters have already been created.
Building canisters...
Installing canisters...
Installing code for canister SilverDIP20, with canister ID hntki-mqaaa-aaaap-qaubq-cai
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed while trying to install all canisters.
    Failed to install wasm module to canister 'SilverDIP20'.
      Failed to install wasm in canister 'hntki-mqaaa-aaaap-qaubq-cai'.
        Failed to install wasm.
          The replica returned an HTTP Error: Http Error: status 503 Service Unavailable, content type "application/cbor", content: Canister hntki-mqaaa-aaaap-qaubq-cai is out of cycles: requested 652544000 cycles but the available balance is 0 cycles and the freezing threshold 0 cycles

The first and second canisters are token canisters using DIP20. (The canister names are different, but they are copies.)

After this, I increased the cycle amount by one digit and tried to deploy the canisters again, but got the same error. The same is true for the another canister.

  • Is there something wrong with my deployment method?
  • Is there a best practice?
  • Or is it just a lack of cycles? (If it is a lack of cycles, the 20T I got from faucet is far from enough, so I have to think of another way).

Thank you in advance for your answer.

There’s a small subtlety in the --with-cycles flag that is the issue: It only triggers when a canister is created. Do you see the line All canisters have already been created. in the log output? This means that --with-cycles has no effect on this deployment.

I would guess you tried your first deployment with --with-cycles <0.1T> (shorthand so that we don’t have to count zeroes), which is exactly how much cycles creating the canister costs. Then the canister has 0 cycles available for computation/uploading code. Installing the wasm fails. Next, you tried with --with-cycles <1T>, which would be plenty, but because the canister is already created, the flag has no effect. UX question: would you expect the --with-cycles flag to top up the canister to the specified amount?

How you can resolve your issue: dfx canister --network ic deposit-cycles 500000000000 SilverDIP20, which would deposit 0.5T cycles from your wallet to the canister with 0 cycles. Then your deployment should work

2 Likes

I had missed the All canisters have already been created.

It only triggers when a canister is created.

I see. I did not understand this part.
Once I deleted all canisters and deployed them, paying attention to the specified amount of cycles, all canisters were successfully deployed!

Thanks again for all your help :slightly_smiling_face:

1 Like