toGWei static method

BigInt toGWei({
  1. required double fromEther,
  2. int decimals = 9,
})

Unit conversion:toGWei

Implementation

static BigInt toGWei({
  required double fromEther, // float value
  int decimals = 9, // eth default
}) {
  /// Conversion unit: 10^x power
  final unit = BigInt.from(10).pow(decimals);

  /// Conversion:
  /// fix: from(double), it will be rounded, resulting in loss of precision, you must do multiplication first

  final ret = BigInt.from(fromEther * unit.toInt());
  Vx.log('convert to gwei: fromEther: $fromEther, unit:$unit, gwei:$ret');
  return ret;
}