Anecdotal Devving

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@penderis·
0.000 HBD
Anecdotal Devving
I have reached a point where I need to start integrating more with Hive, which is rather simple if you are just reading things. It is still kind of simple when you want to do transactions ie.: vote, transfer etc given you are using a library. 

<img src="https://images.ecency.com/DQmbSeyGbg91hyrK72vDv7mgszJ1NMysuaJ3a1ZX3DXrEtD/image.png">

What then?

Well, it is not so simple if you have no library, and seemingly a fundamental feature is also not supported in your language. 

Fortunately, this is the internet and somewhere someone has solved your problem...With a little elbow grease, a person can make something work.

Since I am building in Laravel, and the part which I needed to do a Hive broadcast for is extremely minimal but still best done via the main application, I went on the hunt for something prebuilt. 

Not really surprisingly I only found one or two PHP implementations which considering the landscape is not so bad, for example, preferred JS libraries, options and docs are not exactly many either. 

So all is fair. 

In the Hive Docs there is a bit on signing transactions and extra info, https://developers.hive.io/tutorials-recipes/how-to-serialize-and-sign-using-js.html , and even the signing part can seem pretty intensive if you are building from scratch but the real doozie for me seemed to be the buffer.

So I figured ok fine, it would be good to learn and with this excellent package from @t3ran13 - https://github.com/t3ran13/php-graphene-node-client, surely it won't be such a hassle to just go ahead and implement broadcasting in my app and get on with it. 

There is where I had to just pause for the umpteenth time. Do I really need to? As in, it would take me a good evening or two to port and debug the implementation and I don't know, what if shit changes... 

I am still on the fence but here is what I have decided. 

Since I do not need to be broadcasting and do not really want to be adding Hive code directly to my codebase, well as part of the main app that is. 

I will go the Node.js route, this is purely because the JS libraries get used a lot more and are easily used from backend to client which will become valuable in the coming weeks to me. 

<h2>The problem</h2>

<b>Verify Hive account ownership via a 0.001 HIVE/SBD transfer: </b>
Simple enough, use the PHP Guzzle package to query the Hive chain and loop. 

<b>Return the funds:</b>
See everything leading up to this line. 

<hr><br>

So the problem is not reading, the majority of these libraries solve one big pain in the arse and that is broadcasting to the chain. Although @t3ran13's package is probably good to use as is with Hive but it still had me reconsider using and probably having to maintain my own version. Which is just one of the things which made me go the following route: 

Since I only need to send back the funds for my use case but also do not really want people triggering the execution, the best option for me is just to have a CRON run a js script every minute, loop transfers and batch return them. 

This is easily done using node and pulling the official library used by Hive and that script will just dump the required data to an api end point. 

This helps decouple the Hive aspect a lot more from the app and keeps everything nice and tidy for me on the backend. I can then also continue to build out the "Hive Manager" and host it on different servers. 

Mainly the javascript part or node backend, or even if I change that over to Go or whatever can easily interface and dump data to my main application api and be decoupled through the use of tokens. 

<hr><br>

I am quite happy with that resolve, and yes it is not the end all be all but it is one I can quickly iterate over and implement. Because if you know anything about me, if I can't do it quickly or it hasn't got that grit to keep me interested then I will never do it. 









👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,