transfer_icp function

Future<Variant> transfer_icp(
  1. Caller caller,
  2. String fortheicpid,
  3. IcpTokens mount, {
  4. IcpTokens? fee,
  5. Nat64? memo,
  6. List<int>? subaccount_bytes,
})

Returns the Variant response of this call - the Result<Ok, Err> variant. Check the ICP ledger's candid service file for the specific structure of this variant response to this call.

Implementation

Future<Variant> transfer_icp(Caller caller, String fortheicpid, IcpTokens mount, {IcpTokens? fee, Nat64? memo, List<int>? subaccount_bytes}) async {
    fee ??= IcpTokens.of_the_double_string('0.0001');
    memo ??= Nat64(BigInt.from(0));
    subaccount_bytes ??= Uint8List(32);
    if (subaccount_bytes.length != 32) { throw Exception(': subaccount_bytes-parameter of this function is with the length-quirement: 32-bytes.'); }

    Record sendargs = Record.of_the_map({
        'to' : Blob(hexstringasthebytes(fortheicpid)),
        'memo': memo,
        'amount': mount,
        'fee': fee,
        'from_subaccount': Option<Blob>(value: Blob(subaccount_bytes)),
        'created_at_time': Option<Record>(value: Record.of_the_map({
            'timestamp_nanos' : Nat64(get_current_time_nanoseconds())
        }))
    });
    Variant transfer_result = c_backwards(await SYSTEM_CANISTERS.ledger.call(calltype: CallType.call, method_name: 'transfer', put_bytes: c_forwards([sendargs]), caller: caller))[0] as Variant;
    return transfer_result;
}