Execute Function:
dfx canister call delta topUpICP "(\"55e47c8bf6b9d8df5ab02d9ace26c212424b644dcc9cdef59e74f0243ae80055\",1)"
function code:
public func topUpICP(address : Hex.Hex, amount : Nat) : async ICPledger.TransferResult {
switch (Hex.decode(address)) {
case (#ok(accountIdentifier)) {
let (isOk, accIdPart) = LedgerAccount.validateAccountIdentifier(accountIdentifier);
if (not isOk) {
Debug.trap("AccountIdentifier verification failed");
};
let principal = Principal.fromBlob(Blob.fromArray(accountIdentifier));
Debug.print(debug_show (principal));
await ICPledger.icrc1_transfer({
from_subaccount = null; //?Blob.fromArray(LedgerAccount.defaultSubaccount());
to = {
owner = principal;
subaccount = null;
};
amount = amount * 10 ** 8;
fee = null;
memo = null;
created_at_time = null;
});
};
case (#err(err)) {
Debug.trap(err);
};
};
};
Error result:
Error: Failed update call.
Caused by: Failed update call.
The replica returned a replica error: Replica Error: reject code CanisterReject, reject message IC0503: Canister br5f7-7uaaa-aaaaa-qaaca-cai trapped explicitly: failed to decode call arguments: Custom(Fail to decode argument 0 from table0 to record {
to : record { owner : principal; subaccount : opt vec nat8 };
fee : opt nat;
memo : opt vec nat8;
from_subaccount : opt vec nat8;
created_at_time : opt nat64;
amount : nat;
}
Caused by:
0: input: 4449444c076c06fbca0106c6fcb60202ba89e5c20405a2de94eb060382f3f3910c01d8a38ca80d7d6e786e7d6e046d7b6e046c02b3b0dac30368ad86ca8305030100012055e47c8bf6b9d8df5ab02d9ace26c212424b644dcc9cdef59e74f0243ae80055_000000000080c2d72f
table: type table0 = record {
25_979 : table6;
5_094_982 : table2;
1_213_809_850 : table5;
1_835_347_746 : table3;
3_258_775_938 : table1;
3_573_748_184 : nat;
}
type table1 = opt nat64
type table2 = opt nat
type table3 = opt table4
type table4 = vec nat8
type table5 = opt table4
type table6 = record { 947_296_307 : principal; 1_349_681_965 : table3 }
wire_type: principal, expect_type: principal
1: Deserialize error: Deserialize error: Bytes is longer than 29 bytes.), error code None