Skip to content

Yasuui/tiny-blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. Clone the repository:
git clone https://github.com/yourusername/tiny-blockchain.git cd tiny-blockchain
  1. Create and activate a virtual environment (recommended):
python -m venv .venv source .venv/bin/activate # On Windows, use: .venv\Scripts\activate
  1. Install 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

  1. Blocks: Each block contains:

    • Index
    • Timestamp
    • List of transactions
    • Previous block's hash
    • Current block's hash
  2. Transactions: Simple transfers between addresses with amounts

  3. Mining:

    • Miners solve proof of work puzzles
    • Successful mining adds new blocks
    • Miners receive rewards
  4. Proof of Work:

    • Adjustable difficulty
    • SHA-256 hashing
    • Verification mechanism

Contributing

Show support by ⭐ project

Credits

This project is based on the following resources:

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Education implementation of blockchain technology: Tiny Blockchain

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages