Hey all! Can anyone shed some more-official light onto how many cycles a canister can hold? Iāve been experimenting it looks like 10^14.
Iām working on a goofy recreation of the āMillion Dollar Homepageā, and my plan was to let āusersā buy pixels by sending Cycles along with their request. It all works, but since the canister the full once you deploy to your local replica, all the cycles I send just get refunded.
Is there a way to burn cycles that isnāt just executing a big for loop? Maybe a way to extract cycles from a canister? Or, maybe just a way to configure how many cycles the canister is deployed with?
I suspect your code needs to add a call to ExperimentalCycles.accept(amount : Nat) : Nat to actually accept the funds sent on the call - unless explicitly accepted, the funds will be refunded.
To transfer funds with an intercanister call, call ExperimentalCycles.add(amount : Nat) : () before making the call.
Iām not sure how to arrange for a JS call to transfer funds from the user wallet to your service, but hopefully someone else can answer that one (and your other questions).
Ah, sorry, I didnāt read your question carefully enough.
Iām not aware of any way for dfx to specify the initial cycle allocation for a local install.
As a workaround, which is kinda slow and expensive, you can get your actor to dynamically install a dummy canister using an actor class that you either discard or let hang around. Any cycles you put on the actor class instantiation will be transferred to the fresh canister and die if and when that canister is deleted, freeing up capacity in the main canister.
This repo provides two methods, burn and burnFast, One is slow because it creates and destroys the other canister, requiring more rounds of concensus. The other is fast, because it just leaks the fresh canister after transferring the cycles.
Iāve cleaned up the examples a bit and added a third method:
burn just creates a new actor, passing cycles to it, but doesnāt cleanup the new actor;
burnBetter uses the systemās management canister to additionally delete the temporary actor.
burnBest uses the systemās management canister to just create and delete an empty canister, without even installing a Motoko actor (or requiring a dummy Motoko actor class).