A decentralized blockchain implementation using Go and libp2p for peer-to-peer networking.
- P2P Networking: Built with libp2p for decentralized communication
- Proof of Work: Mining blocks with adjustable difficulty
- Cryptographic Security: SHA-256 hashing and digital signatures
- Real-time Sync: Automatic blockchain synchronization across peers
- Blockchain Explorer: Web interface for monitoring the network
- Docker Support: Easy deployment with containers
- Comprehensive Testing: Unit tests and network tests
- REST API: Full API for blockchain operations
- WebSocket: Real-time updates via WebSocket
What This Project Has (Very Basic Blockchain for learning purpose)
- ✅ Core Blockchain Features
- ✅ Block structure with hash chaining
- ✅ Proof of Work (basic mining)
- ✅ P2P networking with libp2p
- ✅ Block validation
- ✅ Chain synchronization
- ✅ Modern Features
- ✅ Web interface
- ✅ REST API
- ✅ Real-time updates
- ✅ Docker deployment
What's Missing - alot haha
- Transactions
- ❌ No transaction system
- ❌ No digital signatures
- ❌ No transaction validation
- ❌ No UTXO or account-based model
- Consensus Mechanisms
- ❌ No real consensus (just basic PoW)
- ❌ No Byzantine fault tolerance
- ❌ No finality guarantees
- ❌ No fork resolution
- Security
- ❌ No cryptographic signatures
- ❌ No private/public key pairs
- ❌ No wallet system
- ❌ No transaction fees
- Network Layer
- ❌ No peer discovery
- ❌ No NAT traversal
- ❌ No message routing
- ❌ No network resilience
- Storage & Persistence
- ❌ No persistent storage
- ❌ No database integration
- ❌ No state management
- ❌ No pruning
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Node A │◄──►│ Node B │◄──►│ Node C │
│ ┌─────────────┐ │ │ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │ Blockchain │ │ │ │ Blockchain │ │ │ │ Blockchain │ │
│ └─────────────┘ │ │ └─────────────┘ │ │ └─────────────┘ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
- Go 1.25
- Git
- Docker (optional)
# Clone the repository
git clone https://github.com/yourusername/pow-blockchain-libp2p
cd pow-blockchain-libp2p
# Install dependencies
make deps
# Build the application
make build# Start first node
make run
# Start second node (in another terminal)
make run
# Connect nodes
connect /ip4/127.0.0.1/tcp/8080/p2p/QmPeerID# Build and run with Docker Compose
make docker-run
# Or build Docker image
make docker# Terminal 1
make run
# Add BPM: 75
# Terminal 2
make run
# Connect to first node
# Add BPM: 80# Start 3 nodes and watch them sync!
make test-network# Start API server with web interface
make api
# Visit http://localhost:8080Access the blockchain explorer:
# Start with explorer
make api
# Visit http://localhost:8080Create .env file:
NODE_PORT=8080
DIFFICULTY=4
MINING_REWARD=10
BLOCK_TIME=10# Run tests
make test
# Run benchmarks
make bench
# Test network
make test-network
# Coverage analysis
make coveragePoWblockchain-libp2p/
├── cmd/ # Application entry points
│ ├── node/ # Blockchain node
│ └── api/ # API server
├── internal/ # Private application code
│ ├── blockchain/ # Blockchain logic
│ ├── consensus/ # Consensus algorithms
│ └── network/ # P2P networking
├── pkg/ # Public library code
│ ├── crypto/ # Cryptographic functions
│ └── utils/ # Utility functions
├── web/ # Web interface
├── scripts/ # Utility scripts
├── docker/ # Docker configuration
GET /api/v1/blocks- Get all blocksGET /api/v1/blocks/:index- Get block by indexPOST /api/v1/blocks- Add new blockGET /api/v1/status- Get blockchain statusGET /api/v1/peers- Get connected peersPOST /api/v1/connect- Connect to peerGET /api/v1/ws- WebSocket connection
blockchain- Full blockchain updatenew_block- New block addedstatus- Network status update
# Install dependencies
make deps
# Format code
make fmt
# Run linter
make lint
# Run tests
make test
# Generate documentation
make docs- Create feature branch
- Implement feature
- Add tests
- Update documentation
- Submit pull request
Build Errors
# Clean and rebuild
make clean
make buildDocker Issues
# Rebuild Docker image
docker-compose down
docker-compose up --build