ethereumjs-units
or #ethereumjs on freenode
Unit conversion utility.
There are two methods:
convert(value, unitFrom, unitTo)
- convert a value between two unitslazyConvert(value, unitTo)
- include unit type in the input and the output
The value
and the output in all cases is a string.
Examples
Units.convert('1', 'eth', 'wei')
Units.convert('1', 'wei', 'eth')
Units.convert('1', 'finney', 'eth')
Units.lazyConvert('1 eth', 'wei')
Units.lazyConvert('1 wei', 'eth')
Units.lazyConvert('1 finney', 'eth')
Units
Units are defined in units.json
. It is compatible with web3.js and additionally includes ETH
.