Withdraw cycles with deleting canister

I was wondering if there is functionality for transfering/withdrawing cycles from a cansiter without

  • Deleting canister
  • Custom canister code that sends cycles on a request to another canister

Not a big deal, just curious. I put a few too many cycles in certain canisters and would rather not delete/remake it or write some custom code to do this

1 Like

I usually put something like this in all my canisters:

public func wallet_receive() : async  Nat  {
      let amount = Cycles.available();
      let accepted = amount;
      let deposit = Cycles.accept(accepted);

    public shared(msg) func wallet_send(amount : Nat, principal: Principal) : async  Nat  {
        if(msg.caller == __admin){
            let available = Cycles.available();
            if(available >= amount){
                let remote : actor {wallet_receive : () -> async Nat} = actor(Principal.toText(principal));
                let result = await remote.wallet_receive();
                return result;

        return 0;


When the cycles ledger goes live you’ll be able to just deposit them to a ledger account straight from the canister which will be easier.