@rsksmart/btc-eth-unit-converter
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Rootstock

btc-eth-unit-converter

Tool to provide safe conversion between units in BTC and ETH

Installation

npm install @rsksmart/btc-eth-unit-converter

Usage

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.

Sample

A sample file showing how to use the library is included under sample/ directory. To run the sample file:

node run sample/sample.js

Test

To run test with coverage, run:

npm run test

Contributing

Any comments or suggestions feel free to contribute or reach out at our discord server.

Package Sidebar

Install

npm i @rsksmart/btc-eth-unit-converter

Weekly Downloads

36

Version

1.0.0

License

MIT

Unpacked Size

71.9 kB

Total Files

9

Last publish

Collaborators

  • mirisarri
  • josedahlquist
  • nathanieliov
  • jeremy.then