I have a similar issue where I’m getting an “Insufficient funds” error while I’m sure the account has funds.
In my case I’m using the icrc2_approve
method, like so:
public shared ({ caller }) func approve(allowance : Nat) : async Result.Result<IcpLedger.BlockIndex, Text> {
let approveArgs : IcpLedger.ApproveArgs = {
spender = {
owner = caller;
subaccount = null;
};
from_subaccount = null;
amount = 10000000000000;
expected_allowance = ?allowance;
expires_at = null;
fee = ?10000;
memo = null;
created_at_time = null;
};
try {
let approvalResult : IcpLedger.ApproveResult = await IcpLedger.icrc2_approve(approveArgs);
// check if the approval was successfull
switch (approvalResult) {
case (#Err(error)) {
return #err("Couldn't approve funds: " # debug_show (error));
};
case (#Ok(blockIndex)) { return #ok(Nat64.fromNat(blockIndex)) };
};
} catch (error) {
return #err("Reject message: " # Error.message(error));
}
};
I’m getting Couldn't approve funds: #InsufficientFunds({balance = 0})
.
The method is called from the ICP ledger canister, but in the arguments, the spender is the caller which is supposed to be the user
Has anybody run into this before ?
P.S: I’ve tried to trigger my approve method both from the frontend and from the CLI, with different accounts that all have some tokens (i.e account_balance returns a nat) and each time it’s giving me balance = 0.
P.P.S: is there a difference between ICP and LICP locally?