getTransactionByHash method

Future<EtherScanTxByHashModel> getTransactionByHash({
  1. required String? txhash,
})

Returns the information about a transaction requested by transaction hash

hash - Transaction hash

Example

var res = eth.getTransactionByHash(
    txhash: '0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1'
);

Implementation

Future<EtherScanTxByHashModel> getTransactionByHash({
  required String? txhash,
}) async {
  const module = 'proxy';
  const action = 'eth_getTransactionByHash';

  Map<String, dynamic>? query = {
    'txhash': txhash,
    'module': module,
    'action': action,
    'apiKey': apiKey,
  };

  return (await get(query)).fold(
    (l) => EtherScanTxByHashModel.empty(),
    (r) => EtherScanTxByHashModel.fromJson(r),
  );
}