getNativeBalanceMulti method

Future<List?> getNativeBalanceMulti({
  1. required EvmChain chain,
  2. required List<String> addresses,
})

Implementation

Future<List?> getNativeBalanceMulti({
  required EvmChain chain,
  required List<String> addresses,
}) async {
  final String chainn = EvmChainHelper.getChainName(chaintype: chain);
  final Map<String, String> parameters = {
    "chain": chainn,
    for (var address in addresses) "wallet_addresses": address,
  };
  try {
    final response = await _fetch("wallets/balances", parameters: parameters);
    final resData = jsonDecode(response.body);
    Constants.logger.d(resData);
    if (response.statusCode != 200) {
      Constants.logger.w(resData["message"]);
      throw resData["message"];
    } else {
      return resData[0]["wallet_balances"];
    }
  } catch (error) {
    Constants.logger.w(error);
    return null;
  }
}