BS UPdate : Added live price of STEEM/SBD to IDR and vice versa
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
important link
Special thank
- PromoSteem Sponsor :
steemcurator01 , booming, @stephenkendal, @siz-official, @around-theworld - PromoSteem Team :
@arie.steem @ponpase @pojan - Country Representatives
@anroja @ernaerningsih @nazarul @radjasalman @heriadi
Cukop mantap !
Fire / API ?
heheh. this is so ridiculous. I will edit now directly
Congratulations...!!! You Got Upvote 100 %
By: PromoSteem Community
50100200300400500
10002000300040005000
10000