getAccountBalance method
Implementation
Future<String> getAccountBalance(
String adress,
) async {
final res = await networkClient.postHTTP('', {
'jsonrpc': '2.0',
'id': 'dontcare',
'method': 'eth_getBalance',
'params': [adress, 'latest']
});
if (res.isSuccess) {
final hexAmount = res.data['result'].toString();
if (hexAmount == '0x0') {
return '0.0';
}
final eth = EthereumFormater.convertWeiToEth(
convertHexToDecimal(
hexAmount.substring(2),
),
);
return eth.toString();
} else {
return "Error while getting balance";
}
}