Tiny Blockchain
A simple, educational implementation of a blockchain in Python. This project demonstrates the core concepts of blockchain technology including blocks, transactions, proof of work, and mining.
Features
- Block creation and chaining
- Transaction management
- Proof of Work consensus mechanism
- Mining rewards
- Balance tracking
- Basic test suite
Prerequisites
- Python 3.8 or higher
- pip (Python package installer)
Installation
Clone the repository:
git clone https://github.com/yourusername/tiny-blockchain.git cd tiny-blockchainCreate and activate a virtual environment (recommended):
python -m venv .venv source .venv/bin/activate # On Windows, use: .venv\Scripts\activateInstall dependencies:
pip install -r requirements.txt
Usage
Run the example blockchain:
python src/main.py
Run tests:
pytest tests/
Project Structure
tiny-blockchain/
├── src/
│ ├── blockchain.py # Core blockchain implementation
│ ├── proof_of_work.py # Proof of work mechanism
│ └── main.py # Example usage
├── tests/
│ └── test_blockchain.py
└── docs/
└── architecture.md
How It Works
Blocks: Each block contains:
- Index
- Timestamp
- List of transactions
- Previous block's hash
- Current block's hash
Transactions: Simple transfers between addresses with amounts
Mining:
- Miners solve proof of work puzzles
- Successful mining adds new blocks
- Miners receive rewards
Proof of Work:
- Adjustable difficulty
- SHA-256 hashing
- Verification mechanism
Contributing
Show support by ⭐ project
Credits
This project is based on the following resources:
- Learn Blockchains by Building One by Gerald Nash
- Original GitHub Repository
License
This project is licensed under the MIT License - see the LICENSE file for details.
Log in or sign up for Devpost to join the conversation.