Skip to content

πŸš‚ A small Python implementation to begin understanding blockchains

License

Notifications You must be signed in to change notification settings

daneah/toyblocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

toyblocks

Getting Started

>>> import block
>>> my_block = block.Block('some data')
>>> my_block
Block<Hash: 4ce505..., Nonce: None>
>>> my_block.mine()
>>> my_block
Block<Hash: 00006a..., Nonce: 3763>
import block
import blockchain

chain = blockchain.Blockchain()

first = block.Block('first')
second = block.Block('second')
third = block.Block('third')

chain.add_block(first)
chain.add_block(second)
chain.add_block(third)

first.update_data('so broke')

print(chain.broken)  # True

chain.repair()

print(chain.broken)  # False

Credits

Implementation based on behavior observed in Anders Brownworth's Blockchain Demo

About

πŸš‚ A small Python implementation to begin understanding blockchains

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages