$ dfx canister status --all
Canister status call result for samples_backend.
Status: Running
Controllers: 3v2eo-ybud2-stzfo-icwfu-rltti-t35go-w3pyk-ekkbb-aq3ru-ky4vc-oae q4eej-kyaaa-aaaaa-aaaha-cai
Memory allocation: 0
Compute allocation: 0
Freezing threshold: 2_592_000
Memory Size: Nat(332470)
Balance: 3_092_280_573_538 Cycles
Module hash: 0x517238bad4ce03ddfb3a0bea28cca827b0dbd494c2e062233b1ea68e9895a8b8
Canister status call result for samples_frontend.
Status: Running
Controllers: 3v2eo-ybud2-stzfo-icwfu-rltti-t35go-w3pyk-ekkbb-aq3ru-ky4vc-oae q4eej-kyaaa-aaaaa-aaaha-cai
Memory allocation: 0
Compute allocation: 0
Freezing threshold: 2_592_000
Memory Size: Nat(4419605)
Balance: 3_091_888_656_064 Cycles
Module hash: 0x98863747bb8b1366ae5e3c5721bfe08ce6b7480fe4c3864d4fec3d9827255480
“Balance: 3_092_280_573_538 Cycles” was displayed. Why did it show 3_092_280_573_538 instead of 200_000_000_000? Am I not understanding the specifications? Or is it a bug?
This is not a bug, it’s just how it work, and if you have an idea how to improve it, I’d be very happy to hear your suggestions.
The thing is, --with-cycles only has an effect on canister creation. If you already have the canister created, it doesn’t do anything. So you probably created the canister at an earlier point in time, defaulting to ~3T cycles, and then redeployed with --with-cycles, which did not have an effect
@Severin
$ dfx deploy --network ic --with-cycles 1
This resulted in the following error. Perhaps an empty canister was created for 3T cycles?
$ dfx deploy --network ic --with-cycles 1
Deploying all canisters.
Creating canisters…
Creating canister samples_backend…
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed while trying to register all canisters.
Failed to create canister ‘samples_backend’.
The wallet operation failed: An error happened during the call: 4: Creating a canister requires a fee of 100_000_000_000 that is deducted from the canister’s initial balance but only 1 cycles were received with the create_canister request.
$ dfx deploy --network ic --with-cycles 200000000000
Deploying all canisters.
Creating canisters…
Creating canister samples_backend…
samples_backend canister created on network ic with canister id: cgrae-hqaaa-aaaak-aep6q-cai
Creating canister samples_frontend…
samples_frontend canister created on network ic with canister id: cpsly-ryaaa-aaaak-aep7a-cai
Building canisters…
Shrink WASM module size.
Building frontend…
WARN: Building canisters before generate for Motoko
Shrink WASM module size.
Generating type declarations for canister samples_backend:
src/declarations/samples_backend/samples_backend.did.d.ts
src/declarations/samples_backend/samples_backend.did.js
src/declarations/samples_backend/samples_backend.did
Oh, now I see something… The call that shows 3T cycles was made to your local replica, not --network ic. No wonder it took the default amount.
I would expect --with-cycles 1 to produce this error the way it is coded. Canister creation costs 0.1T cycles, and we don’t want to use more cycles than the user specified, therefore if you specify --with-cycles 3000000000000 it will create a canister with 3T - 0.1T = 2.9T cycles. Trying to do this with only 1 cycle therefore fails
Your second attempt with 0.2T cycles worked, and I’d expect your canister to now have a bit less than 0.1T cycles left over
This (implicitly) targets --network local, and does not verify the result of dfx deploy --network ic. You would have to run dfx canister --network ic status --all instead