ICP ledger functions error

i get this error when i call functions from the Ledger Canister.

icp_balance : ()

Request ID: aa5c50026c4cb48ad219166dbb04543901e8c78e66a42ee351121b4fee8d679c
Reject code: 4
Reject text: Fail to decode argument 0 from table0 to record { account : vec nat8 }```
public shared ({ caller }) func icp_balance() : async ICP {
            await ICPLedger.account_balance({
                account = AccountIdentifier.fromPrincipal(caller, null);

AFAIK, you’re calling from an anonymous principal
Try using CLI

dfx canister call your_canister_name icp_balance

1 Like

Your function returns type ‘ICP’. make sure this type aligns with what the account_balance() function returns

1 Like

Hi, I would love to ask a question regarding this.
lets say the canister name is “comp”, and comp has users(callers).
In my code, i call the transfer function from the ledger to transfer icp.

Once the frontend integrates the function and a user(caller) transfers the token, will it work??
Since the args doesn’t take the from field.
or Will the ledger canister assume its the comp canister thats calling the function and not the caller??
How can I go about it??
Since we want users to be able to deposit their icp and withdraw anytime.


public type TransferArg = {
    to : Account;
    fee : ?Nat;
    memo : ?Blob;
    from_subaccount : ?Blob;
    created_at_time : ?Nat64;
    amount : Nat;

There are two options: if you use transfer or icrc1_transfer, then whoever makes the call is the source identity. If the (logged in) frontend makes the call, the the user’s funds are used, if the backend makes the call then the backend’s funds are used. If you want the backend to transfer the user’s funds, you have to use icrc2_transfer_from, which requires icrc2_approve to happen before that.


ohh thanks this clarifies things

I get this error when i call the transfer func from the fronend.

  Request ID: 8c32fdd3903bff9623d1dbcdbb3ee0f55d8f99746252cd807ecca23e5be3f994
  Reject code: 5
  Reject text: Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: transaction is older than 86400 seconds```

FIxed it already, it has to do with the timestamp field, since Im in a different timezone, so i just made it null.