Skip to content

i8o8i-Developer/Digital-Currency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

 ____  _       _ _        _       ____                                       
|  _ \(_) __ _(_) |_ __ _| |     / ___|   _ _ __ _ __ ___ _ __   ___ _   _ 
| | | | |/ _` | | __/ _` | |____| |  | | | | '__| '__/ _ \ '_ \ / __| | | |
| |_| | | (_| | | || (_| | |____| |__| |_| | |  | | |  __/ | | | (__| |_| |
|____/|_|\__, |_|\__\__,_|_|     \____\__,_|_|  |_|  \___|_| |_|\___|\__, |
         |___/                                                        |___/ 

Digital Currency - I8o8iCoin

A Complete Blockchain Cryptocurrency Implementation With Smart Contracts

GitHub Repo Python License

I8o8iCoin Web Interface


🎯 Overview

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.

Key Highlights

βœ… 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


πŸ”„ Recent Updates

V1.1.0 - Authentication & Privacy Enhancements

  • πŸ” 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

⚑ Features

πŸ”— Blockchain Core

  • 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

πŸ“œ Smart Contracts

  • 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

🌐 Networking

  • 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

πŸ’Ό Wallet System

  • 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

πŸ–₯️ Web Interface

  • 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

πŸ” Security & Monitoring

  • 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

πŸš€ Quick Start

Prerequisites

  • Python 3.8 Or Higher
  • Pip Package Manager
  • Git (For Cloning Repository)

Installation Steps

  1. Clone The Repository

    git clone https://github.com/i8o8i-Developer/Digital-Currency.git
    cd Digital-Currency
  2. 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
  3. 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
  4. Access The Application

First Steps

  1. Create A Wallet - Navigate To Wallet Tab And Click "Create New Wallet"
  2. Get Some Coins - Start Mining Or Request Coins From Faucet
  3. Send Transaction - Use The Transaction Tab To Send Coins
  4. Explore Blockchain - View Blocks And Transactions In The Explorer Tab

πŸ“ Project Structure

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

πŸ› οΈ Technology Stack

Backend Technologies

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

Frontend Technologies

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

Key Dependencies

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

πŸ“‘ API Documentation

Authentication Endpoints

Register User

POST /auth/register
Content-Type: application/json

{
  "username": "your_username",
  "password": "your_password"
}

Login User

POST /auth/login
Content-Type: application/json

{
  "username": "your_username",
  "password": "your_password"
}

Response: { "token": "jwt_token_here" }

Wallet Endpoints

Create Wallet

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 Balance

GET /wallet/balance/<address>
Authorization: Bearer <jwt_token>

Response: { "address": "...", "balance": 100.0, "utxos": [...] }

List Wallets

GET /wallet/list
Authorization: Bearer <jwt_token>

Response: { "wallets": ["address1", "address2", ...] }

Transaction Endpoints

Send Transaction

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

GET /transaction/<tx_id>
Authorization: Bearer <jwt_token>

Response: { "transaction": {...} }

Get Mempool

GET /transaction/mempool
Authorization: Bearer <jwt_token>

Response: { "transactions": [...], "count": 10 }

Blockchain Endpoints

Get Chain

GET /blockchain/chain
Authorization: Bearer <jwt_token>

Response: { "chain": [...], "length": 100 }

Get Block

GET /blockchain/block/<block_id>
Authorization: Bearer <jwt_token>

Response: { "block": {...} }

Mine Block

POST /blockchain/mine
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
  "miner_address": "your_address"
}

Response: { "block": {...}, "reward": 50.0 }

Smart Contract Endpoints

Deploy Contract

POST /contract/deploy
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
  "name": "MyContract",
  "code": "contract_bytecode",
  "creator": "wallet_address"
}

Response: { "contract_id": "...", "address": "..." }

Call Contract

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 State

GET /contract/<contract_id>/state
Authorization: Bearer <jwt_token>

Response: { "state": {...} }

P2P Network Endpoints

Register Peer

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 Peers

GET /node/peers
Authorization: Bearer <jwt_token>

Response: { "peers": ["192.168.1.100:5001", ...], "count": 5 }

Get Node Info

GET /node/info
Authorization: Bearer <jwt_token>

Response: { "node_id": "...", "version": "1.0.0", "peers": 5, "blocks": 100 }

Staking Endpoints (PoS)

Stake Coins

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 Info

GET /stake/<address>
Authorization: Bearer <jwt_token>

Response: { "address": "...", "amount": 1000.0, "weight": 0.15 }

Monitoring Endpoints

Prometheus Metrics

GET /metrics

Response: Prometheus Format Metrics

Health Check

GET /health

Response: { "status": "healthy", "uptime": 3600 }

🎨 Frontend Interface

Theme Customization

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 */
}

UI Components

  1. Dashboard - Overview Of Wallet Balance, Recent Transactions, Network Status
  2. Wallet Manager - Create, Import, And Manage Multiple Wallets
  3. Transaction Form - Send Coins With Address And Amount
  4. Blockchain Explorer - Browse Blocks And Transactions
  5. Smart Contracts - Deploy And Interact With Contracts
  6. Mining Panel - Start/Stop Mining, View Mining Stats
  7. Network Panel - Manage P2P Connections And Peers
  8. Settings - Configure Node Options

Custom Popup System

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");

βš™οΈ Configuration

Backend Configuration (BackEnd/Config.py)

# 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 Hour

Environment Variables

You Can Override Config Settings With Environment Variables:

export FLASK_PORT=5000
export CONSENSUS_TYPE=pos
export JWT_SECRET=my-secret-key

πŸ‘¨β€πŸ’» Development

Setting Up Development Environment

  1. Clone And Install

    git clone https://github.com/i8o8i-Developer/Digital-Currency.git
    cd Digital-Currency
    python Start_BackEnd.py
  2. Run Tests (If Available)

    python -m pytest tests/
  3. Code Style

    • Follow PEP 8 Guidelines
    • Use Pascal Case For UI Text
    • Comment Complex Logic

Project Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Web Browser   β”‚
β”‚  (Frontend UI)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ HTTP/WebSocket
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Flask API     β”‚
β”‚  (App.py)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β–Ό         β–Ό          β–Ό         β–Ό
β”Œβ”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”
β”‚Walletβ”‚  β”‚Txns β”‚  β”‚Blockchainβ”‚  β”‚P2P  β”‚
β””β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”˜
    β”‚         β”‚          β”‚         β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Storage  β”‚
        β”‚(SQLite)  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Adding New Features

  1. Backend - Add Endpoint In App.py, Implement Logic In Appropriate Module
  2. Frontend - Add UI Component In index.html, Add Logic In App.js
  3. Testing - Test API With Postman Or Curl, Test UI In Browser
  4. Documentation - Update This README And API Docs

🀝 Contributing

We Welcome Contributions! Here's How To Get Started:

  1. Fork The Repository

    git fork https://github.com/i8o8i-Developer/Digital-Currency.git
  2. Create Feature Branch

    git checkout -b feature/amazing-feature
  3. Make Changes

    • Write Clean, Documented Code
    • Follow Existing Code Style
    • Test Your Changes Thoroughly
  4. Commit Changes

    git commit -m "Add Amazing Feature"
  5. Push To Branch

    git push origin feature/amazing-feature
  6. Open Pull Request

    • Describe Your Changes
    • Reference Any Issues
    • Wait For Review

Contribution Guidelines

  • βœ… 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

πŸ“„ License

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.


⚠️ Disclaimer

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.

Security Considerations

  • πŸ”’ 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

Known Limitations

  • 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)

Use Cases

βœ… 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


πŸ“ž Support & Contact


πŸŽ‰ Acknowledgments

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! ⭐

About

I8o8iCoin: A Decentralized Cryptocurrency Featuring A Custom Blockchain With PoW/PoS/DPoS Consensus, Smart Contracts, And P2P Networking

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors