getTransactionByBlockNumberAndIndex method Null safety

Future<EtherScanTxByHashModel> getTransactionByBlockNumberAndIndex (
  1. {required String? tag,
  2. required String? index}
)

Returns information about a transaction by block number and transaction index position

tag - Tag to look up

index - Index

Example

var res = eth.getTransactionByBlockNumberAndIndex(
   tag: '0x10d4f',
   index: '0x0'
);

Implementation

Future<EtherScanTxByHashModel> getTransactionByBlockNumberAndIndex({
  required String? tag,
  required String? index,
}) async {
  const module = 'proxy';
  const action = 'eth_getTransactionByBlockNumberAndIndex';

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

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