Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rohan-deshpande/cryptocurrency-decimals
Utility library for formatting cryptocurrency coins and token amounts to the correct number of decimal places
https://github.com/rohan-deshpande/cryptocurrency-decimals
crypto cryptocurrency javascript
Last synced: 2 days ago
JSON representation
Utility library for formatting cryptocurrency coins and token amounts to the correct number of decimal places
- Host: GitHub
- URL: https://github.com/rohan-deshpande/cryptocurrency-decimals
- Owner: rohan-deshpande
- License: mit
- Created: 2018-06-12T23:04:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-20T08:08:52.000Z (over 6 years ago)
- Last Synced: 2024-10-11T00:33:18.557Z (3 months ago)
- Topics: crypto, cryptocurrency, javascript
- Language: JavaScript
- Homepage:
- Size: 62.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cryptocurrency-decimals
Simple utility library for formatting cryptocurrency coins and token amounts to the correct number of decimal places
## Installation
```bash
npm i cryptocurrency-decimals --save
```## Usage
```javascript
import decimals, { decimalize } from 'cryptocurrency-decimals';const btcAmount = 0.99884421;
const price = 10213;
const usdtAmount = decimalize(btcAmount * price, 'USDT');// logs 10201.19
console.log(usdtAmount);// logs 8
console.log(decimals['BTC']);
```## Symbols
Currently only a few symbols are supported, please submit a PR to add more!
```bash
ADA
AUD
AUDT
BCH
BTC
ETH
NANO
NEO
USD
USDT
VEN
XRB
XRP
```