Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

heat-sdk | live DEX USD to HEAT

node v6.17.1
version: 1.0.0
endpointsharetweet
/* Sample shows how to convert USD to HEAT with help of HEAT-SDK */ /* Feel free to change the price and click green RUN to run script */ var PRICE_IN_USD = "100.00" var {HeatSDK} = require("heat-sdk") var sdk = new HeatSDK() function getBTCUSD() { return fetch("https://api.bitfinex.com/v1/pubticker/btcusd") .then(response => response.json()) .then(response => response.bid) } function getHEATBTC() { return sdk.api.get("/exchange/market/5592059897546023466/0/0/0") .then(response => String(parseInt(response.lastPrice) * 0.00000001)) } function getHEATUSD() { return getBTCUSD().then(btcusd => getHEATBTC().then(heatbtc => String((parseFloat(btcusd) * parseFloat(heatbtc)))) ) } getHEATUSD().then(heatusd => { var total = parseFloat(PRICE_IN_USD) / parseFloat(heatusd) console.log(`${PRICE_IN_USD} dollar equals ${total} HEAT`) })
Loading…

no comments

    sign in to comment