Many questions are interesting but the answers are not obvious or easy to get. For example: Who comments most in the last 24 hours?
I am going to show you a pattern to find out the answers to such questions using SteemJs.
Get Current Lastest Block
We need to get the latest block number on the steem blockchain, and we can work out roughly the last 24 hours block range by subtracting 206024 (3 seconds a block).
1 | function getBlockchainData() { |
The current block number is:
1 | const blockchain = await getBlockchainData(); |
Getting the Block Content
Each block contains transactions, here you would need to parse the list of transactions and look for the particular ones that you are interested. For example, if we want to compute the total producer rewards by witnesses, we can look for “producer_reward”.
1 | function getBlock(block) { |
Writing to Database or a File
We need to write the data into a database, or for simplicity, we can write to a CSV file for later process.
1 | (async function() { |
Of course, if you want to further develop into a tool, you would need a database, and a background daemon that automatically syncs with the blockchain.
Every little helps! I hope this helps!
Steem On!~
Reposted to Blog
If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE
Alternatively, you could proxy to me if you are too lazy to vote!
Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy
Visit me at: https://steemyy.com
This page is synchronized from the post: ‘SteemJs Programming: What Happens on the Steem Blockchain in the Last 24 Hours?’