How to Stream Hive Blockchain Transactions.-- HIVED

in GEMS4 years ago

Hello everyone

Today We are going to stream the blockchain transactions using the official hive library "Hived". In this tutorial, we will write a simple code to stream the transactions on Hive blockchain. The main purpose of this is to help the new developers of the hive blockchain. This will help them understand how things work on this blockchain. Using this code we can create interesting tools like the discord notification bot. The discord notification bot works on this stream block API. it actually streams the blocks and searches for the required transaction then notify the user with discord API.

Let's understand how to stream hive blocks.

var dhive = require('@hivechain/dhive');
var client = new dhive.Client('https://api.hive.blog');

stream = client.blockchain.getBlockStream();

stream.on('data', function(block) {
        console.log(block.transactions)
    })


Save the NPM package first and then run the above script.

image.png

image.png

Each transaction contains operations like vote, comment ,claim_rewards,claim_account etc.

image.png

At this time we are streaming the operations only.

image.png

image.png

Now we will stream the voting only. The code will display the names of voters in real-time.

image.png
Ok!. Now let's stream the transaction and check who voted whom.

image.png

This is just a simple code for learning. You can read the Hive Developers Portal for more information.

Thank you for reading. If you like the post please do upvote and comment
ntitled-1.png

Sort:  

I have picked your post for my daily hive voting initiative, Keep it up and Hive On!!