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,
  7. List<Legation> legations = const [],
})

Implementation

Future<Variant> transfer_icp(Caller caller, String fortheicpid, IcpTokens mount, {IcpTokens? fee, Nat64? memo, List<int>? subaccount_bytes, List<Legation> legations = const [] } ) async {
    fee ??= IcpTokens.oftheDoubleString('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.oftheMap({
        '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.oftheMap({
            '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, legations: legations))[0] as Variant;
    return transfer_result;
}