Hallo,
for this tutorial we’ll see how to display information about a single block with PlutoHash Jupyter Notebook.
First thing to do is to import BlockSci module.
#import BlockSci module
import blocksci
The second thing we need to do is to instantiate the chain object:
# instantiate the chain object
chain = blocksci.Blockchain("/BlockSci/config_file")
Now we select the year in which is contained the block or blocks we want to examine, for this example, we choose the year “2020”
# instantiate the blocks of year 2020 in blocks:
%time blocks = chain.range("2020")
Note that in this cell, before our command, there is %time.
This will show CPU user time, sys, total, and Wall Time of the work done. It’s just performance check, it can be omitted. It can be useful to compare different algorythms performances and see if we can write a better one to do the analysis we want.
Now we select the block at height 625332 within the blocks list of 2020:
block = list(filter((lambda x: x.height == 625332), blocks.to_list()))
Now we’re ready to see some info of this block
We can, obviously see the height of this block. We already know the height in this situation, as we typed it:
print("block.height ", block[0].height)
We can see the total input and output count:
print("Input Count: ", block[0].input_count)
print("Output Count:", block[0].output_count)
We can see the Miner text, if present:
print("Miner text (if present): ",block[0].miner())
As we can see in this block there is not. We can see the difficulty threshold:
print("Difficulty threshold: ",block[0].bits)
This is the sum of the transactions fees of all the transactions:
print("Fees: ",block[0].fee)
Which, togheter with the block_reward (12,5 btc at that time, before the halving to 6,25 happened in May 2020), composes the total reward for this block:
print("Fees: ", block[0].revenue)
We can see the total size of all block data, expressed in bytes:
print("Block size in byte: ",block[0].total_size)
And the total weight of the block
And the total transactions value of this block:
print("Transactions value: ", block[0].output_value/1e8)
And we can see it’s pretty big. In fact in this block there is a 161,500 btc transaction, that, at the time it was executed, was worth $1,120,376,999.68
At the time we write, it is the biggest transaction, in $ value, that has been ever made in Bitcoin history.
See you at the next tutorial,
and don’t forget to smile!
Would you like to analyze the bitcoin blockchain using Python?