https://github.com/viniciusfinger/python-blockchain
Exploring the foundational concepts of blockchain with this simple Python implementation. This project demonstrates the core principles of blockchain, including mining, nonce, SHA-256 hashing, and proof of work. 🧱⛓️
https://github.com/viniciusfinger/python-blockchain
blockchain blockchain-technology cryptocurrency cryptography proof-of-work python
Last synced: about 1 year ago
JSON representation
Exploring the foundational concepts of blockchain with this simple Python implementation. This project demonstrates the core principles of blockchain, including mining, nonce, SHA-256 hashing, and proof of work. 🧱⛓️
- Host: GitHub
- URL: https://github.com/viniciusfinger/python-blockchain
- Owner: viniciusfinger
- Created: 2024-07-24T18:19:49.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-24T18:25:56.000Z (almost 2 years ago)
- Last Synced: 2025-04-12T21:18:28.662Z (about 1 year ago)
- Topics: blockchain, blockchain-technology, cryptocurrency, cryptography, proof-of-work, python
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Blockchain in Python 🐍🧱⛓️
Exploring the foundational concepts of blockchain with this simple Python implementation. This project demonstrates the core principles of blockchain, including mining, nonce, SHA-256 hashing, and proof of work.
## Features
- **Block Structure**: Each block contains data, a nonce, a previous hash, and a SHA-256 hash.
- **Proof of Work**: Implements a proof-of-work algorithm to secure the blockchain.
- **Mining**: Demonstrates the mining process, where a nonce is incremented until a valid hash is found.
- **Chain Integrity**: Ensures the integrity and security of the chain by linking blocks with cryptographic hashes.
- **Simple Python Implementation**: Written in Python, making it easy to understand.
## Prerequisites
Before running the application, ensure you have the following installed:
- **Python 3** 🐍 for running the application
## Getting Started
1. **Clone the repository:**
```bash
git clone https://github.com/viniciusfinger/python-blockchain.git
```
2. **Navigate to the project directory:**
```bash
cd python-blockchain
```
3. **Run the project:**
```bash
python3 main.py
```
## How It Works
1. **Block Creation**: Each block in the blockchain contains transaction data, a nonce, the previous block's hash, and the current block's hash.
2. **Mining**: To add a block to the blockchain, a proof of work must be found by solving a computational puzzle. This involves finding a nonce that, when combined with the block data, produces a hash with a certain number of leading zeros.
3. **Hashing**: SHA-256 is used to create a secure and unique identifier for each block.
4. **Difficulty**: The difficulty and the proof of work prefix are setted in the `blockchain.py` file, so you can change it and test different possibilities.