Help Needed with DeployBalances and MakePayment Functions in Cupolaxs_blockchain Project

I am currently working on a school project called Cupolaxs_blockchain and I am facing some issues with the deployBalances and makePayment functions. I have a due date this Friday and need to deliver a working payment system for this booking project. The project is supposed to have a demo on a local DFX replica.

Project Overview

The project involves managing token balances, booking cells, and handling payments. The backend is written in Motoko and the frontend is built using modern web technologies.

Issues

DeployBalances Function: The deployBalances function is not initializing correctly. I am getting the following error messages:

Should call deployBalances() first
2024-06-11 08:39:41.397483 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Attempting to deposit cycles:
2024-06-11 08:39:41.397483 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 0
2024-06-11 08:39:41.397483 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] No cycles available to deposit. Please send cycles to the canister.
2024-06-11 08:39:42.708929 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 08:39:42.708929 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 0
2024-06-11 08:39:42.708929 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Not enough cycles. Please deposit more cycles.

MakePayment Function: The makePayment function is also not working as expected. It seems like the App canister is not initialized properly. Here is a snippet of the error:

sudo dfx cycles top-up bkyz2-fmaaa-aaaaa-qaaaq-cai 
100000000
WARN: If you retry this operation, use --created-at-time 1718094482148167000
Error: The replica returned a rejection error: reject code 
DestinationInvalid, reject message Canister um5iw-rqaaa-aaaaq-qaaba-cai not found, error code Some("IC0301")

Code Snippets

Here are some relevant code snippets from the main.mo file:

public shared(msg) func deployBalances() : async () {
    switch (balances) {
        case (?bal) Debug.print("Balances already deployed");
        case (_) {
            let requiredCycles = 7_692_307_692; // Example required cycles for canister creation
            let availableCycles = ExperimentalCycles.available();
            Debug.print("Available cycles:");
            Debug.print(debug_show(availableCycles));
            if (availableCycles < requiredCycles) {
                Debug.print("Not enough cycles. Please deposit more cycles.");
                return;
            };
            let accepted = ExperimentalCycles.accept<system>(requiredCycles);
            assert (accepted == requiredCycles);
            Debug.print("Accepted required cycles for Balances deployment");
            let tempBalances = await Balances.Balances({
                name = "MyToken";
                symbol = "MTK";
                decimals = 8;
                fee = 0;
                initial_balances = [];
                minting_account = null;
                transfer_fee = null;
                metadata = [];
                advanced_settings = null;
                max_supply = 1_000_000_000_000_000_000; // Example max supply
                min_burn_amount = 0; // Example min burn amount
            });
            balances := ?tempBalances;
            Debug.print("Balances deployed successfully");
        };
    }
};

Balances.mo is a ICRC1 intergratin:

import Option "mo:base/Option";
import ExperimentalCycles "mo:base/ExperimentalCycles";
import Icrc1 "mo:icrc1/ICRC1";
import Types "/Types";
import Debug "mo:base/Debug";

import Text "mo:base/Text";
import Nat8 "mo:base/Nat8";


shared ({ caller = _owner }) actor class Balances(
    token_args : Icrc1.TokenInitArgs,
) : async Icrc1.FullInterface {



    stable let token = Icrc1.init({
        token_args with minting_account = Option.get(
            token_args.minting_account,
            {
                owner = _owner;
                subaccount = null;
            },
        );
    });

    type UserId = Types.UserId;
    type Result = Types.Result;


    /// Functions for the ICRC1 token standard
    public shared query func icrc1_name() : async Text {
        Icrc1.name(token);
    };

    public shared query func icrc1_symbol() : async Text {
        Icrc1.symbol(token);
    };

    public shared query func icrc1_decimals() : async Nat8 {
        Icrc1.decimals(token);
    };

    public shared query func icrc1_fee() : async Icrc1.Balance {
        Icrc1.fee(token);
    };

    public shared query func icrc1_metadata() : async [Icrc1.MetaDatum] {
        Icrc1.metadata(token);
    };

    public shared query func icrc1_total_supply() : async Icrc1.Balance {
        Icrc1.total_supply(token);
    };

    public shared query func icrc1_minting_account() : async ?Icrc1.Account {
        ?Icrc1.minting_account(token);
    };

    public shared query func icrc1_balance_of(args : Icrc1.Account) : async Icrc1.Balance {
        Icrc1.balance_of(token, args);
    };

    public shared query func icrc1_supported_standards() : async [Icrc1.SupportedStandard] {
        Icrc1.supported_standards(token);
    };

    public shared ({ caller }) func icrc1_transfer(args : Icrc1.TransferArgs) : async Icrc1.TransferResult {
        await* Icrc1.transfer(token, args, caller);
    };

    public shared ({ caller }) func mint(args : Icrc1.Mint) : async Icrc1.TransferResult {
        await* Icrc1.mint(token, args, caller);
    };

    public shared ({ caller }) func burn(args : Icrc1.BurnArgs) : async Icrc1.TransferResult {
        await* Icrc1.burn(token, args, caller);
    };

    // Functions from the rosetta icrc1 ledger
    public shared query func get_transactions(req : Icrc1.GetTransactionsRequest) : async Icrc1.GetTransactionsResponse {
        Icrc1.get_transactions(token, req);
    };

    // Deposit cycles into this canister.
    public shared func deposit_cycles() : async () {
        let amount = ExperimentalCycles.available();
        Debug.print("Attempting to deposit cycles:");
        Debug.print(debug_show(amount));
        if (amount == 0) {
            Debug.print("No cycles available to deposit. Please send cycles to the canister.");
            return;
        };
        let accepted = ExperimentalCycles.accept<system>(amount);
        if (accepted == amount) {
            Debug.print("Deposited cycles successfully");
        } else {
            Debug.print("Failed to deposit cycles");
        };
        Debug.print("Accepted cycles:");
        Debug.print(debug_show(accepted));
    };

    /// Self-deployment logic
    public shared func deploy_self() : async () {
        let requiredCycles = 7_692_307_692; // Example required cycles for canister creation
        let availableCycles = ExperimentalCycles.available();
        Debug.print("Available cycles:");
        Debug.print(debug_show(availableCycles));
        if (availableCycles < requiredCycles) {
            Debug.print("Not enough cycles. Please deposit more cycles.");
            return;
        };
        let accepted = ExperimentalCycles.accept<system>(requiredCycles);
        if (accepted != requiredCycles) {
            Debug.print("Failed to accept required cycles for deployment");
            return;
        };
        Debug.print("Accepted required cycles for deployment");
        Debug.print("Token already initialized");
    };

}

App.mo

import Principal "mo:base/Principal";
import Balances "./Balances";
import Types "./Types";
import Icrc1 "mo:icrc1/ICRC1";


actor class App(balancesAddr: Principal) = this {

  type Result = Types.Result;
  type UserId = Types.UserId;

  let balances = actor (Principal.toText(balancesAddr)) : Balances.Balances;

  public func payment(user: Principal, amount: Nat) : async (Result) {
    let balance = await balances.icrc1_balance_of({ owner = user; subaccount = null });
    if (amount > balance) return #err(#insufficientBalance);

    let myPrincipal = Principal.fromActor(this);
    let transferArgs = {
      from = { owner = user; subaccount = null };
      to = { owner = myPrincipal; subaccount = null };
      amount = amount;
      created_at_time = null;
      fee = null;
      from_subaccount = null;
      memo = null;
    };
    let transferResult = await balances.icrc1_transfer(transferArgs);
    switch (transferResult) {
      case (#Ok(_)) {
        return #ok();
      };
      case (#Err(err)) {
              let customErr = switch (err) {
                case (#BadBurn(_)) #invalidOperation;
                case (#BadFee(_)) #invalidOperation;
                case (#CreatedInFuture(_)) #invalidOperation;
                case (#Duplicate(_)) #invalidOperation;
                case (#GenericError(_)) #invalidOperation;
                case (#InsufficientFunds(_)) #insufficientBalance;
                case (#TemporarilyUnavailable) #invalidOperation;
                case (#TooOld) #invalidOperation;
              };
              return #err(customErr);
            };
          }
  };

};

Main.mo

import Option "mo:base/Option";
import Debug "mo:base/Debug";
import Prim "mo:prim";
import App "/App";
import Result "mo:base/Result";
import Array "mo:base/Array";
import Principal "mo:base/Principal";
import Text "mo:base/Text";
import Nat8 "mo:base/Nat8";
import Balances "/Balances";
import Types "/Types";
import Icrc1 "mo:icrc1/ICRC1";
import ExperimentalCycles "mo:base/ExperimentalCycles";



actor {
    type Result<S, T> = Result.Result<S, T>; 
    type App = App.App;
    type UserId = Principal;
    type Balances = Balances.Balances;
    type CellId = Nat;
    

    type Cell = {
        id: CellId;
        isBooked: Bool;
        bookedBy: ?UserId;
        price: Nat;
        dateStartBooking: Text;
        dateEndBooking: Text;
        status: Types.BookingStatus;
    };


  var app : ?App = null;
  var balances : ?Balances = null;
  
       // Performs initial setup operations by instantiating the Balances and App canisters
    public shared(msg) func deployBalances() : async () {
        switch (balances) {
            case (?bal) Debug.print("Balances already deployed");
            case (_) {
                let requiredCycles = 7_692_307_692; // Example required cycles for canister creation
                let availableCycles = ExperimentalCycles.available();
                Debug.print("Available cycles:");
                Debug.print(debug_show(availableCycles));
                if (availableCycles < requiredCycles) {
                    Debug.print("Not enough cycles. Please deposit more cycles.");
                    return;
                };
                let accepted = ExperimentalCycles.accept<system>(requiredCycles);
                assert (accepted == requiredCycles);
                Debug.print("Accepted required cycles for Balances deployment");
                let tempBalances = await Balances.Balances({
                    name = "MyToken";
                    symbol = "MTK";
                    decimals = 8;
                    fee = 0;
                    initial_balances = [];
                    minting_account = null;
                    transfer_fee = null;
                    metadata = [];
                    advanced_settings = null;
                    max_supply = 1_000_000_000_000_000_000; // Example max supply
                    min_burn_amount = 0; // Example min burn amount
                });
                balances := ?tempBalances;
                Debug.print("Balances deployed successfully");
            };
        }
    };
    // Deposit cycles into this canister.
       public shared func deposit_cycles() : async () {
        let amount = ExperimentalCycles.available();
        Debug.print("Attempting to deposit cycles:");
        Debug.print(debug_show(amount));
        if (amount == 0) {
            Debug.print("No cycles available to deposit. Please send cycles to the canister.");
            return;
        };
        let accepted = ExperimentalCycles.accept<system>(amount);
        if (accepted == amount) {
            Debug.print("Deposited cycles successfully");
        } else {
            Debug.print("Failed to deposit cycles");
        };
        Debug.print("Accepted cycles:");
        Debug.print(debug_show(accepted));
    };

    public func deployApp() : async () {
            switch (app, balances) {
                case (?a, _) Debug.print("Already deployed");
                case (_, null) Debug.print("Should call deployBalances() first");
                case (_, ?bal) {
                    let tempApp = await App.App(Principal.fromActor(bal));
                    app := ?tempApp;
                    Debug.print("App deployed successfully");
                };
            }
        };

        // deployAll() replies immediately after initiating but not awaiting the asynchronous deployments
        public func deployAll() : async () {
            ignore async {
                await deployBalances();
                Debug.print("Deploying Balances");
                if (await isReady()) {
                    await deployApp(); // requires Balances
                    Debug.print("Deploying App");
                } else {
                    Debug.print("Balances deployment failed or not ready");
                }
            };
        };

    // isReady() replies promptly (and is a cheap query)
    public query func isReady() : async Bool {
        switch(balances, app) {
            case (? _, ? _) true;
            case _ false;
        }
    };


    private var cells: [Cell] = [
        { id = 1; isBooked = false; bookedBy = null; price = 0; dateStartBooking = ""; dateEndBooking = ""; status = #pending },
        { id = 2; isBooked = false; bookedBy = null; price = 0; dateStartBooking = ""; dateEndBooking = ""; status = #pending },
        { id = 3; isBooked = false; bookedBy = null; price = 0; dateStartBooking = ""; dateEndBooking = ""; status = #pending },
        { id = 4; isBooked = false; bookedBy = null; price = 0; dateStartBooking = ""; dateEndBooking = ""; status = #pending },
        { id = 5; isBooked = false; bookedBy = null; price = 0; dateStartBooking = ""; dateEndBooking = ""; status = #pending },
        { id = 6; isBooked = false; bookedBy = null; price = 0; dateStartBooking = ""; dateEndBooking = ""; status = #pending }
    ];
    private var users: [UserId] = [];
    
    public func registerUser(user: Principal): async Bool {
         // Check if user already exists
         if (Array.find(users, func(u: UserId): Bool { return u == user; }) == null) {
             // Use Array.append for clarity
             users := Array.append(users, [user]);
             return true;
         };
         return false;
     };
   public func bookCell(user: UserId, id: CellId, startBookingDate: Int): async Bool {
        var found = false;
        cells := Array.map(cells, func(c : Cell) : Cell {
            if (c.id == id and c.status == #pending) {
                found := true;
                return {
                id = c.id;
                isBooked = true;
                bookedBy = ?user;
                price = c.price;
                dateStartBooking = "";
                dateEndBooking = ""; // Reset end booking date
                status = #confirmed;
            };
            };
            return c;
        });
        return found;
    };



    public func updateCellEndDate(id: CellId, newEndDate: Text): async Bool {
          var updated = false;
          cells := Array.map(cells, func(c : Cell) : Cell {
              if (c.id == id and c.isBooked) {
                  updated := true;
                  return {
                      id = c.id;
                      isBooked = c.isBooked;
                      bookedBy = c.bookedBy;
                      price = c.price;
                      dateStartBooking = c.dateStartBooking;
                      dateEndBooking = newEndDate;
                      status = #confirmed;
                  };
              };
              return c;
          });
          return updated;
      };

    
    public query func checkCell(id: CellId): async ?Cell {
        return Array.find(cells, func(c : Cell) : Bool { c.id == id });
    };

    public query func listCells(): async [Cell] {
        return cells;
    };


    public func removeCell(cellId: Nat): async () {
        cells := Array.filter(cells, func(c : Cell) : Bool { c.id!= cellId });
        };

    public func addCell(cell: Cell): async () {
        cells := Array.append(cells, [cell]);
        };

    public query func getCellDetails(cellId: CellId): async ?Cell {
      return Array.find(cells, func(c: Cell): Bool { return c.id == cellId });
    };
        public func setCell(cell: Cell): async () {
        cells := Array.map(cells, func(c : Cell) : Cell {
            if (c.id == cell.id) {
                return cell;
            };
            return c;
        });
    };

    public func removeUser(userId: Principal): async () { 
        users := Array.filter(users, func(u : UserId) : Bool { u!= userId });
        };
    public func addUser(userId: Principal): async () {
        users := Array.append(users, [userId]);
    };

    // Function to set balance for a user
    public func setBalance(user: UserId, amount: Nat): async Bool {
        switch (balances) {
            case (?bal) {
                let mintArgs = {
                    to = { owner = user; subaccount = null };
                    amount = amount;
                    created_at_time = null;
                    memo = null;
                };
                let result = await bal.mint(mintArgs);
                    switch (result) {
                        case (#Ok(_)){
                            Debug.print("Mint succesful");
                            return true;
                        };
                        case (#Err(err)) {
                            let errorMessage = switch (err) {
                                case (#BadBurn { min_burn_amount }) "Bad burn: min burn amount is  ";
                                case (#BadFee { expected_fee }) "Bad fee: expected fee is ";
                                case (#CreatedInFuture { ledger_time }) "Created in future: ledger time is ";
                                case (#Duplicate { duplicate_of }) "Duplicate: duplicate of ";
                                case (#GenericError { error_code }) "Generic error: code";
                                case (#InsufficientFunds { balance }) "Insufficient funds: balance is ";
                                case (#TemporarilyUnavailable) "Temporarily unavailable";
                                case (#TooOld) "Too old";
                            };
                            Debug.print("Mint error: " # errorMessage);
                            return false;
                        };
                    }
                };
                case (_) {
                    Debug.print("Balances not initialized");
                    return false;
                }
            }
            };

  // Function to make a payment from one user to another
    public func makePayment(from: UserId, to: UserId, amount: Nat): async Bool {
        switch (app) {
            case (?a) {
                let result = await a.payment(from, amount);
                switch (result) {
                    case (#ok) {
                        Debug.print("Payment successful");
                        return true;
                    };
                    case (#err(err)) {
                        let errorMessage = switch (err) {
                            case (#bookingNotFound) "Booking not found";
                            case (#insufficientBalance) "Insufficient balance";
                            case (#invalidOperation) "Invalid operation";
                            case (#paymentNotFound) "Payment not found";
                            case (#userNotFound) "User not found";
                        };
                        Debug.print("Payment error: " # errorMessage);
                        return false;
                    };
                }
            };
            case (_) {
                Debug.print("App not initialized");
                return false;
            }
        }
    };

}

What I Need Help With

DeployBalances Function: How can I ensure that the deployBalances function initializes correctly and has enough cycles?

MakePayment Function: How can I properly initialize the App canister to ensure that the makePayment function works as expected?

Any guidance or suggestions would be greatly appreciated. I am on a tight deadline and need to have this working by Friday. Thank you in advance for your help! Best regards,

Full Github Repo:

Commands that begin with dfx cycles attempt to use the cycles ledger, which you don’t have installed. I probably should go and change it in this case to use an alternative method…
Locally, the command to give a canister cycles is dfx ledger fabricate-cycles. This will conjure cycles out of thin air and increase the target canister’s balance

How do you make that call? It looks like you’re not attaching cycles to the call. Can you try this?

dfx canister call <target canister> --wallet $(dfx identity get-wallet) --with-cycles <cycles to attach> deployBalances <argument>
1 Like
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx ledger fabricate-cycles --all
Fabricating 10000000000000 cycles onto cupolaxs_blockchain_backend
Fabricated 10000000000000 cycles, updated balance: 13_092_154_931_731 cycles
Fabricating 10000000000000 cycles onto cupolaxs_blockchain_frontend
Fabricated 10000000000000 cycles, updated balance: 13_091_757_809_477 cycles
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend  --wallet $(dfx identity get-wallet) --with-cycles 9000000000  deployBalances           

2024-06-11 09:13:08.018192 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 09:13:08.018192 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 9_000_000_000
2024-06-11 09:13:08.018192 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Accepted required cycles for Balances deployment
Error: Failed to do wallet call.
Caused by: Failed to do wallet call.
  An error happened during the call: 4: Creating a canister requires a fee of 7_692_307_692 that is deducted from the canister's initial balance but only 0 cycles were received with the create_canister request.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend  --wallet $(dfx identity get-wallet) --with-cycles 9000000000  deployBalances

I call the functions to test them out with the backend candid interface provided at:

Backend canister via Candid interface:
cupolaxs_blockchain_backend: http://127.0.0.1:4943/?canisterId=be2us-64aaa-aaaaa-qaabq-cai&id=bkyz2-fmaaa-aaaaa-qaaaq-cai

Output:

2024-06-11 09:15:18.862004 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Should call deployBalances() first
2024-06-11 09:15:23.450395 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Attempting to deposit cycles:
2024-06-11 09:15:23.450395 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 0
2024-06-11 09:15:23.450395 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] No cycles available to deposit. Please send cycles to the canister.
2024-06-11 09:15:26.080048 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 09:15:26.080048 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 0
2024-06-11 09:15:26.080048 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Not enough cycles. Please deposit more cycles.
2024-06-11 09:15:31.317878 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 09:15:31.317878 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 0
2024-06-11 09:15:31.317878 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Not enough cycles. Please deposit more cycles.
2024-06-11 09:15:31.317878 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Deploying Balances
2024-06-11 09:15:31.317878 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Balances deployment failed or not ready

You may have to give the wallet some extra cycles as well. dfx ledger fabricate-cycles $(dfx identity get-wallet) 9999t

The UI does not allow you to send cycles with your call, so deployBalances will never work if you call it through Candid UI

1 Like

Seems like a different issue with the Wallet

damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx wallet authorize  s7222-pws2u-oao2s-5rz6k-7v52u-widaj-n7tah-kdyqy-p5qss-i3l2v-bqe
Authorized s7222-pws2u-oao2s-5rz6k-7v52u-widaj-n7tah-kdyqy-p5qss-i3l2v-bqe as a custodian.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend  --wallet $(dfx identity get-wallet) --with-cycles 9000000000  deployBalances
2024-06-11 09:23:36.979626 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 09:23:36.979626 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 9_000_000_000
2024-06-11 09:23:36.979626 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Accepted required cycles for Balances deployment
Error: Failed to do wallet call.
Caused by: Failed to do wallet call.
  An error happened during the call: 4: Creating a canister requires a fee of 7_692_307_692 that is deducted from the canister's initial balance but only 0 cycles were received with the create_canister request.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx wallet balance    
93.768 TC (trillion cycles).
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx wallet name   
Error: Failed to call query function 'name' on wallet.
Caused by: Failed to call query function 'name' on wallet.
  Failed to construct wallet canister caller: Certificate verification failed.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx wallet name

So i need to alway call it with the front end or the direct Terminal command? I tought i can test it with the backend always

damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx identity set-wallet bkyz2-fmaaa-aaaaa-qaaaq-cai
Checking availability of the canister on the network...
Error: Failed to construct wallet canister caller: Certificate verification failed.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend makePayment '(principal "s7222-pws2u-oao2s-5rz6k-7v52u-widaj-n7tah-kdyqy-p5qss-i3l2v-bqe", principal "d3ubx-ngebm-gcgat-ggwoc-jd23u-bdbjy-svns7-zrb5q-4dwa2-d7wsy-7ae", 100)'
2024-06-11 09:33:18.050291 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] App not initialized
(false)
damianbitel@re-byods-145-109-185-159 Coupla % dfx canister call cupolaxs_blockchain_backen deposit
_cycles
Error: Cannot find canister id. Please issue 'dfx canister create cupolaxs_blockchain_backen'.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backen deposit_cycles
Error: Cannot find canister id. Please issue 'dfx canister create cupolaxs_blockchain_backen'.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend deposit_cycles
2024-06-11 09:35:02.345749 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Attempting to deposit cycles:
2024-06-11 09:35:02.345749 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 0
2024-06-11 09:35:02.345749 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] No cycles available to deposit. Please send cycles to the canister.
()
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend d
eployBalances
2024-06-11 09:35:20.233627 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 09:35:20.233627 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 0
2024-06-11 09:35:20.233627 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Not enough cycles. Please deposit more cycles.
()
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend  --wallet $(dfx identity get-wallet) --with-cycles 9000000000  deployBalances
2024-06-11 09:35:37.469460 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 09:35:37.469460 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 9_000_000_000
2024-06-11 09:35:37.469460 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Accepted required cycles for Balances deployment
Error: Failed to do wallet call.
Caused by: Failed to do wallet call.
  An error happened during the call: 4: Creating a canister requires a fee of 7_692_307_692 that is deducted from the canister's initial balance but only 0 cycles were received with the create_canister request.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend makePayment '(principal "s7222-pws2u-oao2s-5rz6k-7v52u-widaj-n7tah-kdyqy-p5qss-i3l2v-bqe", principal "d3ubx-ngebm-gcgat-ggwoc-jd23u-bdbjy-svns7-zrb5q-4dwa2-d7wsy-7ae", 100)'
2024-06-11 09:36:02.334160 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] App not initialized
(false)
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend deployApp                                                                    
2024-06-11 09:36:15.360204 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Should call deployBalances() first
()
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend  --wallet $(dfx identity get-wallet) --with-cycles 9000000000  deployBalances
2024-06-11 09:36:27.795756 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 09:36:27.795756 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 9_000_000_000
2024-06-11 09:36:27.795756 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Accepted required cycles for Balances deployment
Error: Failed to do wallet call.
Caused by: Failed to do wallet call.
  An error happened during the call: 4: Creating a canister requires a fee of 7_692_307_692 that is deducted from the canister's initial balance but only 0 cycles were received with the create_canister request.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend  --wallet  --with-cycles 9000000000  deployBalances
error: a value is required for '--wallet <WALLET>' but none was supplied

For more information, try '--help'.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx wallet

damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx wallet name
Error: Failed to call query function 'name' on wallet.
Caused by: Failed to call query function 'name' on wallet.
  Failed to construct wallet canister caller: Certificate verification failed.
damianbitel@re-byods-145-109-185-159 Coupla % sudo dfx canister call cupolaxs_blockchain_backend  --wallet bnz7o-iuaaa-aaaaa-qaaaa-cai  --with-cycles 9000000000  deployBalances
2024-06-11 09:39:18.431363 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Available cycles:
2024-06-11 09:39:18.431363 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 9_000_000_000
2024-06-11 09:39:18.431363 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Accepted required cycles for Balances deployment
Error: Failed to do wallet call.
Caused by: Failed to do wallet call.
  An error happened during the call: 4: Creating a canister requires a fee of 7_692_307_692 that is deducted from the canister's initial balance but only 0 cycles were received with the create_canister request.
damianbitel@re-byods-145-109-185-159 Coupla % 

it seems like someting with a wallet not set up propperly i cant seem to call it, have tried what i can if you have any wise moves would appricate it, can also hop on a Google Meets if you are available

I don’t know what the problem is here

This is not really indicative of a problem with the wallet given the debug prints that show that the cycles are attached properly. The error comes from (overly simplistic) stack traces because the wallet acts as a proxy that attaches cycles to the call. The canister it then forwards the call to traps because canister creation fails, which in turn makes the wallet return the error.

Is this creating another canister? In that case you also need to attach cycles to this call since creating a canister costs cycles. Canister creation costs 100b on mainnet (and a 13th of that locally, which is where the 7+B cycles in the error come from), plus you want to give it some extra cycles to keep running