getTRC20TransferList method

Future<Set<TronTransaction>> getTRC20TransferList({
  1. required String address,
  2. required ERC20Entity trc20,
  3. int start = 0,
  4. int limit = 20,
  5. int direction = 0,
  6. int? start_timestamp,
  7. int? end_timestamp,
})

Implementation

Future<Set<TronTransaction>> getTRC20TransferList({
  required String address,
  required ERC20Entity trc20,
  int start = 0,
  int limit = 20,
  int direction = 0,
  int? start_timestamp,
  int? end_timestamp,
}) async {
  final endpoint =
      "$baseURL/transfer/trc20?address=${address}&trc20Id=${trc20.contractAddress}&start=${start.asQueryString}&limit=${limit.asQueryString}&direction=${direction.asQueryString}&start_timestamp=${start_timestamp.asQueryString}&end_timestamp=${end_timestamp.asQueryString}";

  final result = await getCall<JSON>(endpoint);
  final code = result['code'] as int;

  if (code != 200) {
    throw Exception("Failed to fetch TRC20 Transfer List: $result");
  }
  final data = result['data'] as JsonList;

  return {
    for (final item in data) TronTransaction.fromJson(item, trc20, address),
  }.whereType<TronTransaction>().toSet();
}