getTRC20Balance method

Future<Amount> getTRC20Balance({
  1. required String address,
  2. required ERC20Entity trc20,
})

Implementation

Future<Amount> getTRC20Balance({
  required String address,
  required ERC20Entity trc20,
}) async {
  final addressParameter = base58ToEVM(address, false).padLeft(64, '0');
  final result = await triggerConstantContract(
    address: address,
    contractAddress: trc20.contractAddress,
    functionSelector: "balanceOf(address)",
    parameter: addressParameter,
  );

  final balance_s = result["constant_result"][0] as String;

  final balance_bi = balance_s.toBigIntFromHex;

  return Amount(
    value: balance_bi,
    decimals: trc20.decimals,
  );
}