getEip1559GasPrice method

  1. @override
Future<Map<String, EtherAmount>> getEip1559GasPrice()
override

Returns the EIP1559 gas price in wei for a network.

Returns a Future that completes with a Map containing the following keys:

  • 'maxFeePerGas': An EtherAmount representing the maximum fee per gas.
  • 'maxPriorityFeePerGas': An EtherAmount representing the maximum priority fee per gas.

Implementation

@override
Future<Map<String, EtherAmount>> getEip1559GasPrice() async {
  final fee = await _makeRPCCall<String>("eth_maxPriorityFeePerGas");
  final tip = Uint256.fromHex(fee);
  final mul = Uint256(BigInt.from(100 * 13));
  final buffer = tip / mul;
  final maxPriorityFeePerGas = tip + buffer;
  final maxFeePerGas = maxPriorityFeePerGas;
  return {
    'maxFeePerGas': EtherAmount.fromBigInt(EtherUnit.wei, maxFeePerGas.value),
    'maxPriorityFeePerGas':
        EtherAmount.fromBigInt(EtherUnit.wei, maxPriorityFeePerGas.value)
  };
}