I Made a Program | Account Value in Blurt Wallet App

in blurtdevelopment •  8 months ago 

Okay, technically, I made two programs, but they work together as one.

Estimated Account Value in Blurt's Wallet App

A lot of you have probably noticed already that the wallet app shows the estimated account value again. If you have haven't, take notice the next time you go to the wallet app.


Screen shot of account value in wallet app
Estimated account value is shown again in Blurt's wallet app.



Before this, it was showing NaN, which stands for "not a number".

In order to show the account value, the wallet app needs to get the price from somewhere. It used to get it from an API privately operated by a former Blurt developer.

When that developer left Blurt and turned off his API, the wallet app could no longer reach it to get the price, so it showed NaN because it wasn't getting a number as it was expecting to get.

My Solution

To fix this, I created an API of my own that the wallet app can call to get the current price of Blurt.

I made it in two parts.

The first part is a Python program that gets the current price of BLURT from Hive-Engine, Ionomy, and CoinGecko (which only tracks ProBit at the moment), and it then calculates the average from these three sources and puts it in a JSON file to be accessed by the other program. It does this once every five minutes.

The second part is a program written in Go that listens for requests by the wallet app and returns the price that is stored in the aforementioned JSON file.

I chose to write the first part in Python because that is the programming language I am most familiar with. I wrote the second part in Go because it is super easy to write a webserver or API with Go, and Go programs run very fast, so it doesn't slow down the wallet app when it asks for the price. If you look at the program, you will see that it's very short and there is very little code needed to accomplish what I needed it to.

If you're interested, you can look at the code here.

Adding BLURT Price to Blurt Blog

Since it's possible for any app to get the price from this API, I'm going to add BLURT price in Condenser (that's the name of the program that runs on blurt.blog) as well in the near future.

I was thinking of adding it in the same card where it shows the chain's transaction fees.


Screen Shot of the Trasaction Fees Info Card
I will add BLURT price in this card, below the transaction fees, in both USD and BTC.

Open Source

I have made the program open source and I have put it in Blurt's GitLab repo, so it will always be available even in the case that I would leave Blurt for some reason. I'm not likely to leave Blurt any time soon, but I try to make sure that the project won't be left in a bind if something happens that I am no longer able to work on it.

I'm trying to make sure that Blurt never has a repeat of what happened early this year when the whole site went to the dumpster after a third party that was running a bunch of Blurt's infrastructure privately decided to leave and turned off his servers.

That's All, Folks!

That's pretty much it from me for now.

I just wanted to give you a little update on some of the things I was working on.

Until next time, I hope you all have a great one!


Vote for my witness!

I run a witness node on the Blurt blockchain and I would really appreciate your witness vote.

You can vote for my witness by going here.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!
Sort Order:  

Thank you very much. The work is much more convenient and enjoyable for all users

Wow! @Saboin you are doing an amazing job with developing and repairing Blurt. I know how bad the damage was when the previous Blurt programmer left.

It is really kind and generous of you to put everything in the Blurt Github. Your code will live forever on Blurt and we will always be grateful to you.

It is so refreshing to see the price in the Blurt wallet. Now I feel richer, thanks to you.

Hi, @saboin,

Thank you for your contribution to the Blurt ecosystem.


Please consider voting for the witness @symbionts.
Or delegate to @ecosynthesizer to earn a portion of the curation rewards!

Thank you so much for your work!
This is great!

Thank you for using my upvote tool 🙂
Your post has been upvoted (46.47 %)

Delegate more BP for better support and daily BLURT reward 😉
@tomoyan
https://blurtblock.herokuapp.com/blurt/upvote

Nice work you're doing @saboin.

Would love to work with you soon. Let's say I create a shopping app for people to buy items with Blurt, can you make it possible for the blurt price and USD price to display against each item and be updated in real time??

That should be doable. I don't think it takes too much work to get that working.

First, thank you for all you are doing here for the community.

Second

so it will always be available even in the case that I would leave Blurt for some reason.

Noooooooooooooooooooo

I have to believe that in the coming months and years that so much will be built from your contributions and the communities thankfulness you couldn't even imagine going anywhere.

I keep seeing many wonder why we don't have lots of Dapps like the other chains, and to me its a no brainer with all the stability issues we've faced. Since you came along, we've begun seeing not only stability but additions to the project. If at any time you ever wonder if the community here sees the immense value you add here to Blurt, please save this comment and read it again. You are exactly the fresh breath of air Blurt has needed. You have my, and no doubt many others, immense gratitude for helping solidify what had been much turmoil. Thank you.

Good work. Which Dex did you end up grabbing the price from?

Thank you.

Getting the price from Hive-Engine, Ionomy, and Probit at the moment.

Ok cool so it is an average of the 3?

It’s an average of the three and it is updated once every five minutes.

Ok, thanks for the info and all your hard work again.

Thank you for all the time and work!!

Many thanks! :-)
One request - is it possible to add one extra decimal place to the dollar value eg 0.0064 USD ?
The BTC value will have 10 digits anyway. lol. thx

Yes. I was planning on doing that eventually anyway. That part is in the Condenser code. My API sends average price to eight decimal places.

OK, great - the extra precision also means users won't ask why their total dollar value changes but the "price" doesn't.

Congratulations, your post has been curated by @r2cornell-curate. Also, find us on Discord

Manually curated by @abiga554

logo3 Discord.png

Felicitaciones, su publication ha sido votado por @r2cornell-curate. También, encuéntranos en Discord

Awesome thanks for this! Putting the Blurt price in the fees block is perfect.

Hi @megadrive, please how do I reach out to you privately?

Join https://discord.blurt.world and DM me from there.

Nice work. I still have to learn and develop an app in Go. Hopefully when I’ve finished things on my plate right now.

I still should learn JS. I've been stubborn about not learning JS. I just lookup stuff when I need to. I had to use JS when I fixed the image uploader, but I wouldn't start a program in JS since I'm not familiar enough with it.

I'm just starting in Go. I've only done a few programs with it, but I enjoy the programming language and I want to get into it more. There is a graphene package for Go. I want to fork it eventually and patch it so that it works with Blurt.

I find it's super easy to write a webserver with Go. And the thing is blazing fast and very lightweight since it compiles to a single binary file. It makes it super easy to deploy anything for that reason.

There are different routers available. For the image server, I used Gorilla Mux, which is one of the most popular ones, but for this API, I used one called Gin. Gin is awesome for creating APIs that spit out JSON. It's great for creating a CRUD API, too.

This was an important fix. Now Blurt feels real. It’s real $$$$ ….

Nice work , crypto platforms without pricing api feels empty. You filled up that emptiness