I've been reading about hive interactions for a while now. Sounds like a bit of a dry environment when you want to interact with Hive programmatically! Maybe you will get angry with me for this statement, but when I want to communicate with blockchains like Ether or Sol or this hive, I think the environment is a bit dry and soulless.
Maybe it's because of habit. We have mostly worked with visual environments and now we want to connect with blockchain and its specific environment. This seems a bit challenging especially when you enter the world of code.
But the pleasure you get from this process is definitely worth it. I would like to face this challenge.
In short, I dived into the hive and started interacting.
You can program with Python or JavaScript. Imagine that you can run your code in your browser with JavaScript without any other program and see the results in the Hive blockchain. It was really enjoyable for me.
Blockchains like Ether have a transaction fee to execute their smart contracts, which is one of their weaknesses. You may say that you can go to the test networks and test the contracts, but people like me like to write all the code on the main network and see the result. One of the strengths of Hive is fee. With RC, you can do it without worry.
Of course, provided you know what you are doing. In the first step, I tried to design a trader. I wanted the script to be able to easily make some profit by scalping the hive and fortunately this script was successful and was able to make a small amount of profit.
Of course, this was just a test and not for professional trading! After working for a long time, I noticed something and that was a bit of fatigue in coding.
I had to write and repeat codes to do everything! Reality indicates the implementation of repetitive tasks. Common tasks that you have to repeat over and over again.
I opened Python and started writing a class. My idea was to write a class that can follow, unfollow, vote, comment or post with a few lines of simple code and.....
I want to reduce coding and split duplicates into methods. A class that has a few simple methods that anyone can understand. For this, I made only three files.
One for the main environment to test the class codes (albropy file), one config for the constants required by the program such as username and password of my account and the network nodes I want and.... finally a file called the Hive and content of my class.
I'm still completing this class and I want to complete its basic codes and finally design my desired idea using it. This class will be the base class.
A class with basic codes that is capable of only one trade, but in combination with the final idea, it will be able to recognize points and entry... the way still continues.
What I want this class to do is simplicity. I don't want anyone to know what the codes do. For example, I have a method called follow. Just give it your account in config and desired username and that's it. Followed!!!! simply!
I don't want to get involved in codes for trading. Just behind the curtain, the points are recognized and Bing... that's it
This is my raw class. For example, a few moments ago I noticed that my good friend @incublus had a post.
I want to reblog it. My codes are as follows:
from Hive import *
from Config import *
hive = albro(APIRPC['rpc'])
hive.Reblog(ACCOUNT, 'incublus', 'special-guest-this-week-on')
In this code, just give the post address to the reblog method and that's it
The result was as follows.
After checking, I realized that yes. The program has worked correctly. So this part of the codes worked correctly. Of course, there is still room for work and I have to improve it.
Another thing is joining communities.
I wrote a method called Join, for this it is enough to give it the community you want and that's it....
from Hive import *
from Config import *
hive = albro(APIRPC['rpc'])
hive.Join(ACCOUNT,'hive-195370')
The result of executing the code was as follows.
This part is also done correctly. Of course, there is still work to be done. I still need to improve things more.
My only goal is to get out of the environment a little and move towards simplicity. In such a way that anyone can do anything with a simple command, regardless of the complexity behind the screen.
[hive: @albro]
Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!
Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).
You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.
Congratulations @albro! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
Your next target is to reach 25000 upvotes.
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out our last posts:
These codes look perfect man, thank you so much for the mention :)
Thank you. I'm developing. There will still be optimization. I try to summarize the code behind the scenes. It's very exciting to do it yourself. Thank you very much for your support because I'm still at the beginning ....🙏