BS UPdate : Added live price of STEEM/SBD to IDR and vice versa

in Steem Marketing3 years ago (edited)

Screen Shot 2021-06-19 at 23.57.37.png

What is BS ?

BS ( Bank STEEM ) is a web-based swap application that I plan to develop in the near future. where later in this application, steemit users from Indonesia can easily buy steem or SBD with rupiah, and vice versa.

What is the Update today ?

in this update,I have managed to add live prices from steem to rupiah, sbd to rupiah and vice versa. where do I get the live price from? I use the API from id.upbit.com

Live demo : https://bank-steem.web.app/

Why from upbit API?

Among the exchanges that have complete prices for steem and sbd to idr is upbit for now. therefore I took the API from upbit.In addition, for now, upbit is the only one that has stable steem and sbd prices

I took this API in 2 steps. the first i took the API from SBD/STEEM to BTC. after that I took the live price from BTC to IDR. You can see in the short code that I show below.

And why don't I use steemconnect ?

I think this is what you are asking, why not just use steemconnect, you can directly connect to steemit. here I will answer, I do not use steemconnect for security reasons. I don't want something bad to happen in the future. because it involves transactions. I don't want BS users to lose their STEEM or SBD later.

And this app is just an exchange app, so I don't think it's necessary to connect with steemit. just like any other exchange. The steemit account is only used for transaction processing. so when you want to exchange your steem or sbd to IDR, that's where you just make a transaction through steemwallet. you can do this transaction using steemconnect (I will provide a button there later) and you can also transfer manually.

Can we get the code from this application?

Of course, because this application is an open source application. so anyone can see it. I accidentally uploaded this app on my github. you can see at this link: https://github.com/sogatanco/bank-steem.

here my summary code:


getPrice(){
        fetch('https://id-api.upbit.com/v1/ticker?markets=BTC-SBD')
        .then(response=>response.json())
        .then((data)=>{
            fetch('https://id-api.upbit.com/v1/ticker?markets=IDR-BTC')
            .then(responseb=>responseb.json())
            .then((btc)=>{
                this.setState({sbdPrice:data[0].trade_price*btc[0].trade_price})
            })  
        })

        fetch('https://id-api.upbit.com/v1/ticker?markets=BTC-STEEM')
        .then(response=>response.json())
        .then((data)=>{
            fetch('https://id-api.upbit.com/v1/ticker?markets=IDR-BTC')
            .then(responseb=>responseb.json())
            .then((btc)=>{
                this.setState({steemPrice:data[0].trade_price*btc[0].trade_price})
            })  
        })
        var hasil;
        if(this.state.from==='IDR'&& this.state.to==='STEEM'){
            hasil=this.state.fromValue/this.state.steemPrice;
        }else if(this.state.from==='IDR'&& this.state.to==='SBD'){
            hasil=this.state.fromValue/this.state.sbdPrice;
        }else if(this.state.from==='STEEM'&& this.state.to==='IDR'){
            hasil=this.state.fromValue*this.state.steemPrice;
        }else if(this.state.from==='SBD'&& this.state.to==='IDR'){
            hasil=this.state.fromValue*this.state.sbdPrice;
        }

        this.setState({toValue:hasil})
      }

Prof of Work

Screen Shot 2021-06-15 at 22.57.19.png

important link

Special thank

kind Regards

@sogata

Sort:  
 3 years ago 

Cukop mantap !

 3 years ago 

I took this fire in 2 steps. the first i took the API from SBD/STEEM to BTC. after that I took the live price from BTC to IDR. You can see in the short code that I show below.

Fire / API ?

 3 years ago 

heheh. this is so ridiculous. I will edit now directly

Congratulations...!!! You Got Upvote 100 %
By: PromoSteem Community

Alternative links delegates to @promosteem.com
50100200300400500
10002000300040005000
10000

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63398.53
ETH 2660.51
USDT 1.00
SBD 2.77