79707790

Date: 2025-07-20 06:56:37
Score: 2
Natty:
Report link

I finally solved the issue!

The problem was with how I defined the checkBalance function in Motoko. I had written:

public shared query func checkBalance(): async Nat {
  return currentValue;
};

While this looks fine, it caused the method to not appear in the Candid UI and failed in dfx canister call as well.

Fix: I read the documentation on Query functions and removed the return keyword and simply returned the value directly like this:

public shared query func checkBalance(): Nat {
  currentValue;
};

After making the fix, I also ran these commands to ensure a clean redeploy:

dfx stop
rm -rf .dfx
dfx start --clean
dfx deploy

Now everything works perfectly! The solution was so much more simple than I made it out to be. Hope this helps someone facing the same issue!

Reasons:
  • Whitelisted phrase (-1): Hope this helps
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): facing the same issue
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Priya Gurung