Update bitcore guide

This commit is contained in:
Yemel Jardi 2014-12-25 19:14:06 -03:00
parent e7839d9ba2
commit 168d87185c
1 changed files with 16 additions and 0 deletions

View File

@ -61,3 +61,19 @@ value = Unit.fromBTC(amount).mBTC;
value = Unit.fromBTC(amount).bits; value = Unit.fromBTC(amount).bits;
value = Unit.fromBTC(amount).satoshis; value = Unit.fromBTC(amount).satoshis;
``` ```
## Using a fiat currency
The unit class also provides a convenient alternative to create an instance from a fiat amount and the corresponding BTC/fiat exchange rate. Any unit instance can be converted to a fiat amount by providing the current exchange rate. Check the example below:
```javascript
var unit, fiat;
var amount = 100;
var exchangeRate = 350;
unit = new Unit(amount, exchangeRate);
unit = Unit.fromFiat(amount, exchangeRate);
fiat = Unit.fromBits(amount).toFiat(exchangeRate);
fiat = Unit.fromBits(amount).to(exchangeRate);
```