getting Byteball to input currency exchange in the input you provided with bot.

The API link refers to CoingGecko and arr[2] refers to 2nd argument of your input to bot.

For e.g. you write 10 to btc and send that to bot now 10 is arr[0], to is arr[1] and btc is arr[2]. So arr[0] and arr[2] we only need for code. Other if-else are conditions to get right input parameter from the user.

Now interesting part…

Coin Gecko only supports currency conversion from any conversion to main currencies like btc, ltc, etc. So if you say 10 to steem then you will get NaN. Because that is not supported.

To overcome it let’s dive deeper, That is under if condition where the value is NaN

We do it now:- We will get 10 to steem or anything that exists on coin gecko with this method.

Convert Byteball to main currency like btc

Now take that currency like steem and get it’s BTC value too.

Now keep in mind that….

`1 GB worth of btc * 1 Btc worth of Steem = 1 GB worth of Steem`

4. That way you can get arr[0]*1GB to steem value. Get it? Take your time if it’s new for you.

5. So after adding that formula we have 10 to steem value or any other currency we want exists on CoinGecko and the coin will be recognized by the id like to call Lite coin, You use ltc e.g. 11 to ltc.

The output will be like.

You can easily convert vice versa by doing division instead of multiplication.