Hello, you weird people who read my blog. Sorry , could not post yesterday. Not well.
Welcome to part 3. Today we will learn how to Get your blog and your profile from the blockchain. Analyze its various parts.\
If this is your first visit, then please visit my blog and read the previous posts to get up-to-date.
The first step is to get your profile/account from the blockchain
Step 1
The method field will be "method":"get_accounts",
the params will be "params":[["hispeedimagins"]]
Notice the double arrays in the params field. You can add more account names or only send one. Your choice.
example of multiple account name : "params":[["hispeedimagins","jonknight"]]
there you go.
The full json will be
{
"id":"37",
"jsonrpc":"2.0",
"method":"get_accounts",
"params":[["hispeedimagins"]]
}
The result is
Now let us look at a few values
"voting_power": 9800,
"last_vote_time": "2018-03-13T03:36:09",
that is your voting power. It decreases every-time you vote. As you will already know. Now the thing is that this value is only updated by the server after a vote has been cast by you. So for calculating the true voting power, the formula is
effective voting power = (((Current time epoch - last_vote_time_epoch)/1000 * 5)* 10000) + voting_power
Date format of last_vote_time = "yyyy-MM-dd'T'hh:mm:ss"
confused? Well you convert the current time in epochs, subtract it from the last voting time in epochs and then convert the whole thing to seconds. Because epochs are in microseconds. Now we again divide this by 5, because voting power regenerated to full in 5 days, so we find out how much time is over. Multiply the whole thing by 10000, the full power value and you get how much voting power has been restored. Now add it to the voting power and you have the effective voting power.
Example
(1520934243 - 1520912169) = 21734. These are already in seconds so no need to divide by 1000
21734/432000 = 0.0503108
0.0503108 * 10000 = 503
my voting power which was at 9800 + 503 = 10300. Max is 10000 so my voting power is full as of now.
The jsonmetadata is where your profile data resides. It is a json within itself. you have to extract it.
The next field is the reputation field.
"reputation": "403286615138",
Not the pretty two digit number you look at. How to calculate it?
((Math.log10(reputation) - 9) * 9) + 25
Example
Math.log10(403286615138) = 11.605613
11.605613 - 9 = 2.605613
2.605613 * 9 = 23.450517
23.450517 + 25 = 48.45
That is my rep. yay.
We have concluded how to get your profile, how to calculate your effective voting power and to calculate your rep.
Now on to the second part. Get your blog from the blockchain.
The request will remain the same except that we will change the params value to this
["database_api","get_state", ["/@hispeedimagins/blog"]]
change hispeedimagins to your name. hahah now that is an agent smith pun. the rest remains the same.
Note: get state api will be changed soon, under the new appbase api format. I will keep you guys updated.
the full request in json is
{
"id":34,
"jsonrpc":"2.0",
"method":"call",
"params":["database_api","get_state", ["/@hispeedimagins/blog"]]
}
this will be your response.
All of the values are self explanatory. If you need help with one comment below.
We will only analyze one portion of the result. this array is available on all the posts with votes on them. If no votes then this will be null.
"active_votes": [
{
"voter": "jonknight",
"weight": 32034,
"rshares": "8397346078",
"percent": 10000,
"reputation": "2536377476524",
"time": "2018-03-13T05:27:06"
}
]
We will understand a few values, they will come useful for the next part.
- percent is the percentage of vote power used by the voter. In this case, @jonknight. Thank you i might add.
- weight is what we calculate which is the multiplication of the percent selected with voting power you have left.
- rshares is what we use to calculate how much of the reward pool money will you get.
Well, that seems to be a huge data dump for today. We have covered a lot. Have formulae with live examples.
Tomorrow we will see how to calculate the vote value and perhaps one more request.
If you have any questions ask them in the comments.
Have a nice day.
Curious to see your vote value computation. I've had to slog through that not too long ago. Didn't occur to me to post about it though :). Will let you do the honors.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thank you. :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Wow this is awesome and i have learnt from it @hispeedimagins
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
he he. thank you
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey there mate. Thanks for sharing this, I am a beginner when it comes to programming and I am still trying to learn a lot of things. And this kind of helps me understand the steem api a bit better.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
you are welcome
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Have you considered posting your tutorials at uptopian.io? They reward open source contributions and tutorials, as well as translation and other attention intensive tasks.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
TBH I did not know that. Or how to do it. Ill try sniffing around. Thank you :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit