Steem Api tutorial Part 2

programming-3186084_1280.png

Hello. So you are back. Well that is nice. If you are new. Please check the first part here

Well now that we have got that out of the way.

Today we will begin where we left off. The last time we got the global properties from the blockchain. This time we will first see how to get one block from the chain and analyze what the data means.

Step 1

open postman. Well that was simple. Go on, pat yourself on the back. Have a snack.

Step 2

Make the global properties request again. We will use the last_irreversible_block_num from it. You can also use the head_block_num if you wish to. The names are self explanatory.

Request result
stem1.png

Helpful tip: you can save your requests in the cloud using postman by making a free account, or by just saving them to your disk. Just press CTR+S in windows. I think it should be the same in other operating systems. Make a request folder in the prompt , add a name and keep saving all your requests. You will not lose your work.

Step 3

Now we will make the request body.

This time the method name will be call.

The params field will not be blank. Duh. We have to send the block number.

A quick explanation of an object and an array.
An object is donated by

{
"hispeedimagins":"smart"
}

hehe, just as before. An object begins and closes with curly brackets. We can supply names. The left hand side is the name, the right is the value.

An array starts and ends with square brackets.

[
"hispeedimagins","smart"
]

You only supply values in an array. Separate them with commas . In this "hispeedimagins" and "smart" are both values.
This will all come in useful later on.

For our field params we will supply and array, and inside of that another array.

["database_api","get_block",["20557408"]]

The first value is the function to call within the method. The second is the sub function. The third is the value. Our irreversible block number, we got from before.

The full request body is this.

{

    "id":"40",
    "jsonrpc":"2.0",
    "method":"call",
    "params":["database_api","get_block",["20557408"]]

}

Result is
stem2.png

A small explanation of the result is in order.

  1. Number 4 is the last block id. It is a block chain.
    Number 6 is the witness who processed it. It is @aggroed. This was totally coincidental. Yay.

If you have not voted for witnesses, please go ahead and do it now. Let us not elect idiots like we have IRL.

  1. Number 10 is an array of transactions held by this block. Did you think each transaction gets its own block? What are you, the queen of England?

  2. Numbers 12 and 13 refer to previous block id's and numbers. We will learn how to calculate them later. Relax you did not miss anything. The are important because they refer to previous blocks, so if a fork happens the transactions are not repeated.

  3. Number 15 is an array of operations. Yes you can send multiple operations in a single transaction. This one is for a vote.
    The permlink is what comes at the end of the url. It is made from the title of the post. Write funny titles so devs can laugh when they are banging their heads when something is not working.

  4. Number 22 is the weight field. This is the vote percent. Yes it is 3300, your eyes are not that weak, or you are not that drunk. Regardless eat your green vegetables and drink less.
    The weight seen by the blockchain ranges from 1 to 10000. So the percentage of this vote is 3300/10000 * 100. Which is 33%.
    Give your 100% vote here, full 10000. hehehhe.

the signatures field is calculated, which we will cover after sometime.

Did you read the whole thing. Congratulations. You are a nerd. Or have no life. Or possibly both , like me. Yay.
Have any questions? Well don't keep them to yourself. You are reading a tutorial . Ask them in the comments.

Have a good day. or night.

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center