____ _ _ _ _ ____
| _ \(_) __ _(_) |_ __ _| | / ___| _ _ __ _ __ ___ _ __ ___ _ _
| | | | |/ _` | | __/ _` | |____| | | | | | '__| '__/ _ \ '_ \ / __| | | |
| |_| | | (_| | | || (_| | |____| |__| |_| | | | | | __/ | | | (__| |_| |
|____/|_|\__, |_|\__\__,_|_| \____\__,_|_| |_| \___|_| |_|\___|\__, |
|___/ |___/
A Complete Blockchain Cryptocurrency Implementation With Smart Contracts
Digital Currency Is A Full-Featured Blockchain Cryptocurrency Platform With A Complete Backend Implementation And Modern Web Interface. Built From Scratch With Python And Vanilla JavaScript, It Demonstrates Core Blockchain Concepts Including Multiple Consensus Algorithms, Smart Contracts, P2P Networking, And Secure Wallet Management.
β
Multiple Consensus Mechanisms - Proof Of Work (PoW), Proof Of Stake (PoS), Delegated Proof Of Stake (DPoS)
β
Smart Contract Engine - Full Script Execution With OpCode Support
β
P2P Network - WebSocket-Based Peer Discovery And Gossip Protocol
β
UTXO Model - Bitcoin-Style Transaction Management
β
RESTful API - Complete Flask Backend With JWT Authentication
β
Modern Web UI - Bright Green Theme With Retro Aesthetics
β
Virtual Environment - Automated Setup With Python Scripts
-
π User Authentication System
- Implemented Mandatory Login Requirement For Accessing Application Features
- JWT-Based Authentication With Secure Token Management
- User Registration And Login With Password Hashing
-
π Wallet Privacy & Security
- Wallets Are Now Attached To Individual Users For Privacy
- Users Can Only View And Manage Their Own Wallets
- Authentication Required For Wallet Creation And Access
-
π¨ UI Improvements
- Increased Base Font Size To 20Px For Better Readability
- Enhanced User Interface With Login-Protected Main Content
- Improved Authentication Flow With Proper Error Handling
-
π‘οΈ Backend Security
- Added Authentication Middleware To Wallet-Related Endpoints
- User Data Isolation And Secure API Access
- Enhanced Error Handling And User Feedback
-
Multi-Consensus Support
- Proof Of Work (PoW) With Adjustable Difficulty
- Proof Of Stake (PoS) For Energy Efficiency
- Delegated Proof Of Stake (DPoS) With Voting System
-
Transaction Management
- UTXO Model For Security And Transparency
- Transaction Mempool With Priority Queue
- Multi-Input/Multi-Output Transactions
- Transaction Validation And Verification
-
Block Management
- Genesis Block Creation
- Block Propagation And Validation
- Chain Reorganization Support
- Merkle Tree Implementation
-
Script Engine
- Stack-Based Execution Model
- OpCode Support (OP_DUP, OP_HASH160, OP_CHECKSIG, OP_IF, OP_RETURN)
- Contract State Management
- Event Emission System
-
Contract Features
- Deploy Custom Contracts
- Execute Contract Functions
- Query Contract State
- Listen To Contract Events
-
P2P Protocol
- Peer Discovery Mechanism
- Gossip-Based Propagation
- WebSocket Real-Time Communication
- Peer Quality Scoring System
-
Network Features
- Automatic Peer Connection
- Block And Transaction Broadcasting
- Node Synchronization
- Network Health Monitoring
-
Key Management
- ECDSA Key Pair Generation
- Schnorr Signature Support
- Hierarchical Deterministic (HD) Wallets
- Secure Private Key Storage
-
Wallet Operations
- Create Multiple Wallets
- Check Balance And UTXOs
- Send And Receive Transactions
- Transaction History Tracking
-
Modern Design
- Bright Green Theme With Retro Elements
- Responsive Layout For All Devices
- Custom Modal Popups And Notifications
- Pixelated Typography Effects
-
Interface Features
- Wallet Management Dashboard
- Transaction Creation Form
- Blockchain Explorer
- Smart Contract Deployment
- Mining Controls
- Network Peer Management
- Real-Time Status Updates
-
Authentication
- JWT Token-Based Authentication
- Password Hashing (bcrypt)
- Session Management
- Rate Limiting Protection
-
Monitoring
- Prometheus Metrics Export
- Comprehensive Logging System
- API Request Tracking
- Network Health Checks
- Python 3.8 Or Higher
- Pip Package Manager
- Git (For Cloning Repository)
-
Clone The Repository
git clone https://github.com/i8o8i-Developer/Digital-Currency.git cd Digital-Currency -
Start Backend Server
python Start_BackEnd.py
This Script Will:
- Create A Virtual Environment
- Install All Dependencies From
Requirements.txt - Start The Flask Server On Port 5000
-
Start Frontend Server (In A New Terminal)
python Start_FrontEnd.py
This Script Will:
- Start HTTP Server On Port 8080
- Automatically Open Your Browser To
http://localhost:8080
-
Access The Application
- Frontend UI: http://localhost:8080
- Backend API: http://localhost:5000
- API Docs: http://localhost:5000/apidocs
- Create A Wallet - Navigate To Wallet Tab And Click "Create New Wallet"
- Get Some Coins - Start Mining Or Request Coins From Faucet
- Send Transaction - Use The Transaction Tab To Send Coins
- Explore Blockchain - View Blocks And Transactions In The Explorer Tab
Digital-Currency/
β
βββ BackEnd/ # Backend Python Application
β βββ __init__.py # Package Initializer
β βββ App.py # Flask API Server (Main Entry Point)
β βββ BlockChain.py # Blockchain Logic And Block Management
β βββ Config.py # Configuration Settings
β βββ Consensus.py # Consensus Algorithms (PoW, PoS, DPoS)
β βββ Crypto.py # Cryptographic Functions (ECDSA, Schnorr)
β βββ logger.py # Logging Utilities
β βββ P2PNetwork.py # Peer-To-Peer Networking
β βββ P2PStr.py # P2P Protocol Structures
β βββ SmartContract.py # Smart Contract Engine
β βββ Storage.py # SQLite Database Operations
β βββ Transaction.py # Transaction Creation And Validation
β βββ Wallet.py # Wallet And Key Management
β βββ Data/ # Data Storage Directory
β βββ Wallets.json # Wallet Storage File
β
βββ FrontEnd/ # Frontend Web Application
β βββ index.html # Main HTML File
β βββ Css/ # Stylesheets
β β βββ Retro.css # Bright Green Retro Theme
β βββ Js/ # JavaScript Files
β βββ App.js # Frontend Application Logic
β
βββ Source/ # Additional Source Files
β βββ Proxy.php # PHP Proxy (Optional)
β
βββ Start_BackEnd.py # Backend Startup Script (With Venv)
βββ Start_FrontEnd.py # Frontend HTTP Server Script
βββ Requirements.txt # Python Dependencies
βββ LICENSE # MIT License
βββ README.md # This File
| Component | Technology | Purpose |
|---|---|---|
| Runtime | Python 3.8+ | Core Programming Language |
| Web Framework | Flask 2.3.0 | RESTful API Server |
| Database | SQLite3 | Data Persistence |
| Cryptography | ECDSA, Hashlib | Digital Signatures And Hashing |
| Networking | WebSockets | Real-Time P2P Communication |
| Authentication | JWT (PyJWT) | Token-Based Auth |
| Monitoring | Prometheus Client | Metrics Collection |
| Documentation | Flasgger | Swagger API Docs |
| Component | Technology | Purpose |
|---|---|---|
| Markup | HTML5 | Structure |
| Styling | CSS3 | Bright Green Theme With Retro Effects |
| Scripting | Vanilla JavaScript | Application Logic (No Frameworks) |
| Server | Python http.server | Static File Serving |
Flask==2.3.0
Flask-CORS==4.0.0
Flask-SocketIO==5.3.4
Flask-Limiter==3.3.1
flasgger==0.9.7.1
PyJWT==2.8.0
ecdsa==0.18.0
bcrypt==4.0.1
prometheus-client==0.17.1
python-socketio==5.9.0
websockets==11.0.3
pyyaml==6.0.1
requests==2.31.0
POST /auth/register
Content-Type: application/json
{
"username": "your_username",
"password": "your_password"
}POST /auth/login
Content-Type: application/json
{
"username": "your_username",
"password": "your_password"
}
Response: { "token": "jwt_token_here" }POST /wallet/create
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"name": "My Wallet",
"algorithm": "ecdsa"
}
Response: { "address": "wallet_address", "public_key": "...", "private_key": "..." }GET /wallet/balance/<address>
Authorization: Bearer <jwt_token>
Response: { "address": "...", "balance": 100.0, "utxos": [...] }GET /wallet/list
Authorization: Bearer <jwt_token>
Response: { "wallets": ["address1", "address2", ...] }POST /transaction/send
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"from_address": "sender_address",
"to_address": "recipient_address",
"amount": 10.0,
"private_key": "sender_private_key"
}
Response: { "transaction_id": "...", "status": "pending" }GET /transaction/<tx_id>
Authorization: Bearer <jwt_token>
Response: { "transaction": {...} }GET /transaction/mempool
Authorization: Bearer <jwt_token>
Response: { "transactions": [...], "count": 10 }GET /blockchain/chain
Authorization: Bearer <jwt_token>
Response: { "chain": [...], "length": 100 }GET /blockchain/block/<block_id>
Authorization: Bearer <jwt_token>
Response: { "block": {...} }POST /blockchain/mine
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"miner_address": "your_address"
}
Response: { "block": {...}, "reward": 50.0 }POST /contract/deploy
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"name": "MyContract",
"code": "contract_bytecode",
"creator": "wallet_address"
}
Response: { "contract_id": "...", "address": "..." }POST /contract/<contract_id>/call
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"function": "transfer",
"args": ["recipient", 100],
"caller": "wallet_address"
}
Response: { "result": {...}, "events": [...] }GET /contract/<contract_id>/state
Authorization: Bearer <jwt_token>
Response: { "state": {...} }POST /node/register
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"address": "192.168.1.100:5001"
}
Response: { "message": "Peer registered", "total_peers": 5 }GET /node/peers
Authorization: Bearer <jwt_token>
Response: { "peers": ["192.168.1.100:5001", ...], "count": 5 }GET /node/info
Authorization: Bearer <jwt_token>
Response: { "node_id": "...", "version": "1.0.0", "peers": 5, "blocks": 100 }POST /stake/create
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"address": "wallet_address",
"amount": 1000.0
}
Response: { "stake_id": "...", "amount": 1000.0 }GET /stake/<address>
Authorization: Bearer <jwt_token>
Response: { "address": "...", "amount": 1000.0, "weight": 0.15 }GET /metrics
Response: Prometheus Format MetricsGET /health
Response: { "status": "healthy", "uptime": 3600 }The UI Uses A Bright Green Theme With Retro Aesthetics. Color Scheme:
:root {
--primary-green: #2d7a2d; /* Primary Green */
--bright-green: #3fb83f; /* Bright Accent */
--light-green: #90ee90; /* Light Highlights */
--dark-green: #1a4d1a; /* Dark Shadows */
--bg-light: #f0f4f0; /* Light Background */
--bg-lighter: #fafdfb; /* Lighter Areas */
--text-dark: #1a1a1a; /* Primary Text */
--border-green: #2d7a2d; /* Borders */
}- Dashboard - Overview Of Wallet Balance, Recent Transactions, Network Status
- Wallet Manager - Create, Import, And Manage Multiple Wallets
- Transaction Form - Send Coins With Address And Amount
- Blockchain Explorer - Browse Blocks And Transactions
- Smart Contracts - Deploy And Interact With Contracts
- Mining Panel - Start/Stop Mining, View Mining Stats
- Network Panel - Manage P2P Connections And Peers
- Settings - Configure Node Options
The UI Features Custom Modal Popups Instead Of Browser Alerts:
// Prompt Popup
showPromptPopup("Enter Wallet Name:", "My Wallet", (value) => {
if (value) {
// User Entered Value
}
});
// Confirm Popup
showConfirmPopup("Are You Sure?", (confirmed) => {
if (confirmed) {
// User Confirmed
}
});
// Notification
showNotification("Transaction Sent Successfully!", "success");# Network Settings
HOST = '0.0.0.0'
PORT = 5000
DEBUG = True
# Blockchain Settings
DIFFICULTY = 4
BLOCK_REWARD = 50.0
BLOCK_TIME = 10 # Seconds
# Consensus
CONSENSUS_TYPE = 'pow' # Options: 'pow', 'pos', 'dpos'
# P2P Network
P2P_PORT = 5001
MAX_PEERS = 20
# Database
DB_PATH = 'BackEnd/Data/blockchain.db'
# JWT Secret
JWT_SECRET_KEY = 'your-secret-key-here'
JWT_ACCESS_TOKEN_EXPIRES = 3600 # 1 HourYou Can Override Config Settings With Environment Variables:
export FLASK_PORT=5000
export CONSENSUS_TYPE=pos
export JWT_SECRET=my-secret-key-
Clone And Install
git clone https://github.com/i8o8i-Developer/Digital-Currency.git cd Digital-Currency python Start_BackEnd.py -
Run Tests (If Available)
python -m pytest tests/
-
Code Style
- Follow PEP 8 Guidelines
- Use Pascal Case For UI Text
- Comment Complex Logic
βββββββββββββββββββ
β Web Browser β
β (Frontend UI) β
ββββββββββ¬βββββββββ
β HTTP/WebSocket
βΌ
βββββββββββββββββββ
β Flask API β
β (App.py) β
ββββββββββ¬βββββββββ
β
ββββββ΄βββββ¬βββββββββββ¬ββββββββββ
βΌ βΌ βΌ βΌ
βββββββ βββββββ ββββββββββββ βββββββ
βWalletβ βTxns β βBlockchainβ βP2P β
βββββββ βββββββ ββββββββββββ βββββββ
β β β β
βββββββββββ΄βββββββββββ΄ββββββββββ
βΌ
ββββββββββββ
β Storage β
β(SQLite) β
ββββββββββββ
- Backend - Add Endpoint In
App.py, Implement Logic In Appropriate Module - Frontend - Add UI Component In
index.html, Add Logic InApp.js - Testing - Test API With Postman Or Curl, Test UI In Browser
- Documentation - Update This README And API Docs
We Welcome Contributions! Here's How To Get Started:
-
Fork The Repository
git fork https://github.com/i8o8i-Developer/Digital-Currency.git
-
Create Feature Branch
git checkout -b feature/amazing-feature
-
Make Changes
- Write Clean, Documented Code
- Follow Existing Code Style
- Test Your Changes Thoroughly
-
Commit Changes
git commit -m "Add Amazing Feature" -
Push To Branch
git push origin feature/amazing-feature
-
Open Pull Request
- Describe Your Changes
- Reference Any Issues
- Wait For Review
- β Write Clear Commit Messages
- β Add Comments For Complex Logic
- β Update Documentation
- β Test Before Submitting
- β Follow Pascal Case For UI Text
- β Use Bright Green Theme Colors
This Project Is Licensed Under The MIT License.
MIT License
Copyright (c) 2024 i8o8i-Developer
Permission Is Hereby Granted, Free Of Charge, To Any Person Obtaining A Copy
Of This Software And Associated Documentation Files (the "Software"), To Deal
In The Software Without Restriction, Including Without Limitation The Rights
To Use, Copy, Modify, Merge, Publish, Distribute, Sublicense, And/Or Sell
Copies Of The Software, And To Permit Persons To Whom The Software Is
Furnished To Do So, Subject To The Following Conditions:
The Above Copyright Notice And This Permission Notice Shall Be Included In All
Copies Or Substantial Portions Of The Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
See LICENSE File For Full License Text.
Important Notice:
This Project Is A Proof-Of-Concept And Educational Implementation Of Blockchain Technology. It Is NOT Intended For Production Use Without Extensive Security Audits, Testing, And Hardening.
- π Private Keys - Store Securely, Never Share Or Commit To Git
- π JWT Secrets - Use Strong Random Keys In Production
- π Network Security - Use TLS/SSL For Production Deployments
- π Input Validation - Always Validate User Inputs
- π Rate Limiting - Implement Proper Rate Limits To Prevent Abuse
- Limited Scalability (Suitable For Small Networks)
- Basic Smart Contract Engine (Limited OpCode Set)
- SQLite Database (Not Suitable For High-Throughput)
- No Byzantine Fault Tolerance In Current Implementation
- Simplified P2P Protocol (No Advanced Routing)
β
Learning - Study Blockchain Concepts
β
Research - Experiment With Consensus Algorithms
β
Development - Build Prototypes And POCs
β
Education - Teaching Cryptocurrency Fundamentals
β Production - Not Ready For Real-World Deployments
β Financial - Do Not Use For Real Money Transactions
β Critical Systems - Not Audited For Security Vulnerabilities
- GitHub: @i8o8i-Developer
- Repository: Digital-Currency
- Issues: Report Bug Or Request Feature
Special Thanks To:
- The Open Source Community
- Bitcoin And Ethereum Projects For Inspiration
- All Contributors And Testers
Made With π By i8o8i-Developer
β Star This Repository If You Find It Useful! β
