English 中文(简体)
Blockchain - Adding Genesis Block
  • 时间:2024-11-03

Python Blockchain - Adding Genesis Block


Previous Page Next Page  

Adding a block to the blockchain involves appending the created block to our TPCoins pst.

TPCoins.append (block0)

Note that unpke the rest of the blocks in the system, the genesis block contains only one transaction which is initiated by the originator of the TPCoins system. Now, you will dump the contents of the blockchain by calpng our global function dump_blockchain

dump_blockchain(TPCoins)

When you execute this function, you will see the following output −

Number of blocks in the chain: 1
block # 0
sender: Genesis
-----
recipient:
30819f300d06092a864886f70d010101050003818d0030818902818100ed272b52ccb539
e2cd779c6cc10ed1dfadf5d97c6ab6de90ed0372b2655626fb79f62d0e01081c163b0864
cc68d426bbe9438e8566303bb77414d4bfcaa3468ab7febac099294de10273a816f7047d
4087b4bafa11f141544d48e2f10b842cab91faf33153900c7bf6c08c9e47a7df8aa7e60d
c9e0798fb2ba3484bbdad2e4430203010001
-----
value: 500.0
-----
time: 2019-01-14 16:18:02.042739
-----
--------------
=====================================

At this point the blockchain system is ready to use. We will now enable the interested cpents to become miners by providing them a mining functionapty.

Advertisements