getTransactionByBlockHashAndIndex method
Future<EthereumTransaction?>
getTransactionByBlockHashAndIndex(
- EthereumData? blockHash,
- int? index
Get transaction by block hash and index. Returns information about a transaction by block hash and transaction index position. Hash of a block and integer of the transaction index position. Returns see getTransactionByHash.
Implementation
Future<EthereumTransaction?> getTransactionByBlockHashAndIndex(
EthereumData? blockHash, int? index) async {
if (blockHash == null) {
throw ArgumentError.notNull(
'Ethereum::getTransactionByBlockHashAndIndex - blockHash');
}
if (index == null) {
throw ArgumentError.notNull(
'Ethereum::getTransactionByBlockHashAndIndex - index');
}
final dynamic params = <dynamic>[
blockHash.asString,
EthereumUtilities.intToHex(index)
];
const method = EthereumRpcMethods.getTransactionByBlockHashAndIndex;
final dynamic res = await _client.rpcClient.request(method, params);
if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
return EthereumTransaction.fromMap(res[EthereumConstants.ethResultKey]);
}
_client.processError(method, res);
return null;
}