This project implements a basic blockchain from scratch using Python and Flask. It simulates how blockchain technology works at a fundamental level — including mining blocks, validating proof-of-work, handling transactions, and achieving consensus across multiple nodes in a peer-to-peer network.
-
Block creation with proof-of-work (PoW)
-
Transaction handling between addresses
-
Genesis block initialization
-
SHA-256 hashing of blocks
-
Node registration and peer communication
-
Consensus algorithm to resolve conflicts
-
Flask-based API with endpoints to interact with the blockchain
| Endpoint | Method | Description |
|---|---|---|
/mine |
Get |
Mines a new block and receives reward |
| Endpoint | Method | Description |
|---|---|---|
/transaction/new |
POST |
Creates a new transaction |
| Endpoint | Method | Description |
|---|---|---|
/chain |
Get |
Returns the full blockchain |
| Endpoint | Method | Description |
|---|---|---|
/nodes/register |
POST |
Registers new nodes in the network |
| Endpoint | Method | Description |
|---|---|---|
/nodes/resolve |
Get |
Reaches consensus to ensure valid chain |
-
Create transactions via the /transaction/new endpoint.
-
Mine blocks using proof-of-work via /mine.
-
Link blocks with hashes and maintain integrity.
-
Share blocks across nodes and reach consensus using /nodes/resolve.
-
Python 3
-
Flask (for REST API)
-
requests (for node communication)