toWei static method

BigInt toWei({
  1. required double fromEther,
  2. int decimals = 18,
})

Unit conversion:toWei

Implementation

static BigInt toWei({
  required double fromEther, // float value
  int decimals = 18, // 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 wei: fromEther: $fromEther, unit:$unit, wei:$ret');
  return ret;
}