estimateGas method Null safety

Future<EtherScanRpcResponseModel> estimateGas (
  1. {required String? to,
  2. required String? from}
)

Makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas

from - Receiving Address

to - Sending Address

Example

var res = eth.estimateGas(
    from: '0xdf4221b931b6ad4f4f221e2eb03913bd4368d0ba',
    to: '0x109aa384b8786e55abfa1f0ac6cb0561e0a06e94',
);

Implementation

Future<EtherScanRpcResponseModel> estimateGas({
  required String? to,
  required String? from,
}) async {
  const module = 'proxy';
  const action = 'eth_estimateGas';

  Map<String, dynamic>? query = {
    'apiKey': apiKey,
    'module': module,
    'action': action,
    'to': to,
    'from': from,
  };
  return (await get(query)).fold(
    (l) => EtherScanRpcResponseModel.empty(),
    (r) => EtherScanRpcResponseModel.fromJson(r),
  );
}