SkillAgentSearch skills...

Toyblocks

🚂 A small Python implementation to begin understanding blockchains

Install / Use

/learn @daneah/Toyblocks
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

Related Skills

View on GitHub
GitHub Stars67
CategoryDevelopment
Updated1y ago
Forks14

Languages

Python

Security Score

85/100

Audited on Feb 5, 2025

No findings