go-basic-blockchain

module
v0.0.0-...-fc775d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2025 License: Apache-2.0

README ΒΆ

go-basic-blockchain

Buy Me A Coffee

Educational Blockchain Implementation in Go with Advanced Consensus & Comprehensive Learning Course

Welcome to go-basic-blockchain, an educational project designed to demystify blockchain technology through a hands-on, from-scratch implementation in Go. This project serves as both a comprehensive learning tool and a fully functional blockchain implementation for developers, students, and blockchain enthusiasts.

🎯 Built Completely From Scratch: This blockchain implementation uses no third-party blockchain libraries (no go-ethereum, Bitcoin, Tendermint/Cosmos, etc.) and includes our custom Helios consensus algorithm - all created from the ground up to fully teach Go programming and blockchain development.

πŸš€ NEW: Complete Learning Course - This project now includes a comprehensive 19-section course covering everything from Go fundamentals to production deployment!

🎯 NEW: Fully Functional Blockchain Node - Complete, operational blockchain with continuous mining, proper data persistence, and smooth progress monitoring.

πŸ“š Learning Course

This repository includes a comprehensive learning course with 19 sections organized into 4 phases:

Course Structure
  • Phase 1: Foundation (Sections 1-5) - Go fundamentals and basic blockchain
  • Phase 2: Advanced Features (Sections 6-10) - Advanced consensus and APIs
  • Phase 3: User Experience (Sections 11-15) - Web and mobile applications
  • Phase 4: Production Quality (Sections 16-19) - Testing and deployment
What You'll Learn
  • Go Programming: Master Go fundamentals, concurrency, and advanced patterns
  • Blockchain Development: Build complete blockchain systems from scratch
  • Advanced Consensus: Implement sophisticated consensus algorithms (Helios)
  • API Development: Create professional RESTful APIs with authentication
  • Web Development: Build responsive web applications with React
  • Mobile Development: Create cross-platform mobile apps with React Native
  • Testing: Implement comprehensive testing strategies
  • Deployment: Deploy production-ready applications
Course Features
  • 80-109 hours of comprehensive content
  • 19 sections with hands-on exercises
  • 19 quizzes with detailed answer keys
  • 4 major milestones with working deliverables
  • Production-ready portfolio project

Start Learning β†’ | Complete Course Overview β†’


πŸ”§ Blockchain Implementation

Key Features
  • Built from Scratch: Every component implemented from the ground up
  • Advanced Consensus: Implements the Helios consensus algorithm with three-stage validation
  • Go Programming Language: Utilizing Go's simplicity and efficiency for complex systems
  • Readable JSON Format: Human-readable JSON for data structures and storage
  • No Third-Party Dependencies: Encourages deep understanding of core blockchain concepts
  • Educational Focus: Thoroughly commented and documented with design explanations
  • Optimized Test Suite: Fast, reliable tests with smart scrypt configuration
  • Sidechain Routing: Advanced transaction routing through specialized protocols
  • Continuous Mining: Automatic block creation and mining with proper state management
  • Professional Build System: Organized binary output with cross-compilation support
Current Status
  • Test Coverage: 39.8%
  • Test Suite Performance: ~9.5 seconds (30x faster than before)
  • Implementation Status: ~95% complete
  • Helios Consensus: βœ… Fully integrated and tested
  • Blockchain Functionality: βœ… Fully operational with continuous mining

πŸš€ Quick Start

For Learning
  1. Start with the Learning Course
  2. Follow the structured progression through all 19 sections
  3. Build your blockchain step by step with hands-on exercises
For Blockchain Implementation
  1. Clone the repository:

    git clone https://github.com/yourusername/go-basic-blockchain.git
    cd go-basic-blockchain
    
  2. Install dependencies:

    go mod tidy
    
  3. Run tests to verify everything works:

    make test
    
  4. Start the blockchain node:

    make run
    

    Or run the binary directly:

    ./bin/release/gbbd
    
  5. Access the web interface at http://localhost:8200

πŸ—οΈ Architecture Overview

Helios Consensus Algorithm

The project implements the Helios consensus algorithm, a sophisticated three-stage consensus mechanism:

  1. Stage 1 - Proof Generation: Miners create cryptographic proofs for transaction validation
  2. Stage 2 - Sidechain Routing: Transactions are routed through specialized protocols (BANK, MESSAGE, etc.)
  3. Stage 3 - Block Finalization: Validated blocks are finalized with proof verification
Key Components
  • Blockchain Core: Main blockchain implementation with Helios integration and continuous mining
  • Wallet System: Encrypted wallet management with key derivation
  • API Layer: RESTful endpoints with authentication middleware
  • P2P Network: Peer-to-peer communication framework
  • Sidechain Router: Transaction routing through specialized protocols
  • Test Suite: Comprehensive testing with optimized performance
  • Progress Indicator: Real-time status monitoring with smooth updates
  • Build System: Professional Makefile with cross-compilation and organized output

πŸ“Š Project Structure

go-basic-blockchain/
β”œβ”€β”€ learn/                    # Comprehensive learning course (19 sections)
β”‚   β”œβ”€β”€ README.md            # Course overview and navigation
β”‚   β”œβ”€β”€ COURSE_OVERVIEW.md   # Detailed course guide
β”‚   β”œβ”€β”€ phase1/              # Foundation (Sections 1-5)
β”‚   β”œβ”€β”€ phase2/              # Advanced Features (Sections 6-10)
β”‚   β”œβ”€β”€ phase3/              # User Experience (Sections 11-15)
β”‚   └── phase4/              # Production Quality (Sections 16-19)
β”œβ”€β”€ cmd/                     # Application entry points
β”‚   β”œβ”€β”€ gbb-cli/            # Command-line interface
β”‚   β”œβ”€β”€ chaind/             # Blockchain daemon
β”‚   └── demo/               # Demo applications
β”œβ”€β”€ internal/               # Core blockchain implementation
β”‚   β”œβ”€β”€ helios/             # Helios consensus algorithm
β”‚   β”œβ”€β”€ menu/               # User interface components
β”‚   └── progress/           # Progress tracking
β”œβ”€β”€ docs/                   # Technical documentation
β”œβ”€β”€ test/                   # Test files and examples
β”œβ”€β”€ bin/                    # Compiled binaries
β”œβ”€β”€ data/                   # Blockchain data storage
β”œβ”€β”€ scripts/                # Build and deployment scripts
└── postman/                # API testing collections

πŸ“š Documentation

Learning Resources
Technical Documentation

πŸ§ͺ Testing

The project includes a comprehensive test suite with optimized performance:

  • Test Coverage: 39.8%
  • Test Execution Time: ~9.5 seconds (30x faster than before)
  • Smart Scrypt Configuration: Automatic switching between test and production security levels
  • Timeout Protection: All tests have 60-second timeouts to prevent hanging
  • Helios Tests: Comprehensive testing of the consensus algorithm
  • Blockchain Tests: All blockchain functionality tests passing

Run tests with:

make test

πŸ”§ Development

Building
make build          # Build release binary
make debug          # Build debug binary with debugging symbols
make build-all      # Build for all platforms (Linux, Windows, macOS, ARM64, AMD64)
Running
make run            # Build and run release binary
make run-bin        # Run existing release binary
make debug          # Build and run debug binary with delve debugger
./bin/release/gbbd  # Run release binary directly
./bin/debug/gbbd    # Run debug binary directly
Testing
make test           # Run all tests
make test-short     # Run short tests
make test-unit      # Run unit tests only
make test-coverage  # Run with coverage
Development
make setup          # Setup dependencies
make fmt            # Format code
make lint           # Run linter
make clean          # Clean build artifacts
make clean-data     # Clean blockchain data
make clean-all      # Clean everything
Release
make release        # Build all cross-compiled binaries
Documentation Generation
make docs

πŸ“ˆ Performance

  • Test Suite: 30x faster execution (9.5 seconds vs 5+ minutes)
  • Scrypt Optimization: Smart configuration for development vs production
  • Memory Usage: Optimized for educational use
  • Network Latency: Minimal overhead in P2P communication
  • Blockchain Operation: Continuous mining with proper state management
  • Progress Display: Smooth, non-flickering status updates

πŸ—οΈ Build System

The project features a professional build system with:

  • Cross-Compilation: Build for Linux, Windows, macOS (ARM64, AMD64)
  • Binary Organization: Separate bin/debug/ and bin/release/ directories
  • Go 1.22 Compatibility: Latest Go version with toolchain specification
  • Dependency Management: Proper go.mod and go.sum handling
  • Clean Targets: Organized cleanup with dependency preservation

🎯 Learning Paths

For Complete Beginners
  1. Start with Phase 1: Foundation
  2. Complete all sections in order
  3. Build your first blockchain in Section 5
  4. Progress through each phase sequentially
For Experienced Developers
  1. Review Phase 1 for Go/blockchain basics
  2. Jump to Phase 2 for advanced features
  3. Focus on Phase 3 for user interfaces
  4. Complete Phase 4 for production deployment
For Specific Skills

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸ“„ License

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


Ready to explore the future of blockchain technology? Choose your path:

πŸŽ“ Start Learning β†’ - Begin the comprehensive 19-section course
πŸ”§ Explore Implementation β†’ - Dive into the technical documentation
πŸš€ Quick Start β†’ - Get the blockchain running immediately

Transform from beginner to production-ready blockchain developer with our complete learning experience!

Directories ΒΆ

Path Synopsis
cmd
chaind command
demo command
gbb-cli command
internal
Package sdk is a software development kit for building blockchain applications.
Package sdk is a software development kit for building blockchain applications.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL