getTransactionCount method
Transaction count, returns the number of transactions sent from an address.
Implementation
Future<int?> getTransactionCount(
EthereumAddress? address, EthereumDefaultBlock? block) async {
if (address == null) {
throw ArgumentError.notNull('Ethereum::getTransactionCount - address');
}
if (block == null) {
throw ArgumentError.notNull('Ethereum::getTransactionCount - block');
}
const method = EthereumRpcMethods.transactionCount;
final blockString = block.getSelection();
final params = <String?>[address.asString, blockString];
final dynamic res = await _client.rpcClient.request(method, params);
if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
return EthereumUtilities.hexToInt(res[EthereumConstants.ethResultKey]);
}
_client.processError(method, res);
return null;
}