Tool to provide safe conversion between units in BTC and ETH
npm install @rsksmart/btc-eth-unit-converter
The following conversion functions are available
- weisToGwei
- weisToEth
- gweisToWeis
- gweisToEth
- ethToWeis
- ethToGweis
- satoshisToBtc
- btcToSatoshis
- weisToSatoshis
- weisToBtc
- ethToSatoshis
- satoshisToWeis
- satoshisToEth
- btcToWeis
For any invalid value (below minimum, negative or base unit decimals) an error will be thrown. Below minimum refers to values that represent an amount lower than the smallest base unit, for example weisToSatoshis(1)
will throw an error because the result is less than 1 satoshi which is the smallest base unit.
A sample file showing how to use the library is included under sample/
directory. To run the sample file:
node run sample/sample.js
To run test with coverage, run:
npm run test
Any comments or suggestions feel free to contribute or reach out at our discord server.