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.
- Block creation and chaining
- Transaction management
- Proof of Work consensus mechanism
- Mining rewards
- Balance tracking
- Basic test suite
- Python 3.8 or higher
- pip (Python package installer)
- Clone the repository:
git clone https://github.com/yourusername/tiny-blockchain.git cd tiny-blockchain
- Create and activate a virtual environment (recommended):
python -m venv .venv source .venv/bin/activate # On Windows, use: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Run the example blockchain:
python src/main.py
Run tests:
pytest tests/
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
-
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
Show support by ⭐ project
This project is based on the following resources:
- Learn Blockchains by Building One by Gerald Nash
- Original GitHub Repository
This project is licensed under the MIT License - see the LICENSE file for details.