Skip to main content

toWei

Callable

  • toWei(number: Numbers, unit: number | noether | wei | kwei | Kwei | babbage | femtoether | mwei | Mwei | lovelace | picoether | gwei | Gwei | shannon | nanoether | nano | szabo | microether | micro | finney | milliether | milli | ether | kether | grand | mether | gether | tether): string

  • Takes a number of a unit and converts it to wei.

    @example
    console.log(web3.utils.toWei("0.001", "ether"));
    > 1000000000000000 //(wei)

    Parameters

    • number: Numbers

      The number to convert.

    • unit: number | noether | wei | kwei | Kwei | babbage | femtoether | mwei | Mwei | lovelace | picoether | gwei | Gwei | shannon | nanoether | nano | szabo | microether | micro | finney | milliether | milli | ether | kether | grand | mether | gether | tether

      EtherUnits The unit of the number passed.

    Returns string

    The number converted to wei.