fetchTokenBalance method

Future<BigInt> fetchTokenBalance({
  1. required String address,
  2. required String contractAddress,
})

Implementation

Future<BigInt> fetchTokenBalance({
  required String address,
  required String contractAddress,
}) async {
  final endpoint = buildTokenBalanceEndpoint(address, contractAddress);
  final result = await fetchEtherscanWithRatelimitRetries<String>(endpoint);

  final balance = BigInt.tryParse(result);

  if (balance == null) {
    throw Exception('Failed to parse balance: $result');
  }

  return balance;
}