Skip to content

streembit/poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Streembit Blockchain

A next-generation blockchain implementation featuring the Proof of Collaboration (PoC) consensus protocol, built with Node.js and TypeScript.

Overview

Streembit Blockchain bridges traditional finance and blockchain technology through legal accountability and cooperative game theory principles. Unlike traditional Proof-of-Work or Proof-of-Stake systems, PoC ensures institutional adoption by combining cryptographic security with real-world legal frameworks.

Key Features

  • Proof of Collaboration (PoC) consensus protocol
  • Accountable Block Creators - Only registered businesses can create blocks
  • Minting Consortiums - Anonymous participation through accountable intermediaries
  • Dual Token System - FOWCoin (FOW) and Streembit Stable Coin (SSC)
  • Legal Integration - Works within existing regulatory frameworks
  • TypeScript Implementation - Type-safe development with strict typing
  • CLI and Web API - Multiple interfaces for different user types

Quick Start

Prerequisites

  • Node.js 20+ (LTS version)
  • npm 9+
  • TypeScript 5.0+

Installation

# Clone the repository
git clone https://github.com/streembit/streembit-blockchain.git
cd streembit-blockchain

# Install dependencies
npm install

# Build the project
npm run build

# Initialize configuration
./dist/cli/index.js init

Running the Node

Interactive Console (Recommended)

# Start integrated console with PoC collaborators
npm run dev

# Expected output:
πŸš€ Streembit Blockchain Interactive Console
πŸ“‹ Collaborators: 2 nodes, 2 eligible

streembit> genesis 1234567890abcdef...
streembit> exit

Collaborator Requirements (all must be true in .env):

  1. ENABLE_COLLABORATOR=true
  2. COLLABORATOR_NODES=streembit-limited-ie,streembit-foundation-us
  3. COLLABORATOR_AUTO_START=true

Other Modes

# Start the blockchain node with API server
npm start

# Start only external CLI
npm run start:cli

# Start only the API server
npm run start:api

Usage

CLI Interface

# Show help
npx streembit --help

# Start blockchain node
npx streembit node start --port 8333

# Create a wallet
npx streembit wallet create --name my-wallet

# Check wallet balance
npx streembit wallet balance

# Send transaction
npx streembit wallet send 0x... 100 --confirm

# Register as validator
npx streembit consensus register --business-cert cert.pem

# View network status
npx streembit network peers

Web API

The API server runs on port 3000 by default:

# Get API information
curl http://localhost:3000/api/v1

# Get latest blocks
curl http://localhost:3000/api/v1/blocks

# Get specific block
curl http://localhost:3000/api/v1/blocks/0x1234...

# Health check
curl http://localhost:3000/health

WebSocket API

Connect to real-time notifications:

const ws = new WebSocket('ws://localhost:3000/ws');

// Subscribe to block notifications
ws.send(JSON.stringify({
  type: 'subscribe',
  channel: 'blocks'
}));

Docker Deployment

Private Key Security with Docker

For production deployments, private keys should never be embedded in Docker images. Instead, use volume mounting to provide secure access:

# Create secure directory on host
sudo mkdir -p /secure/streembit-keys
sudo chmod 700 /secure/streembit-keys
sudo chown $(id -u):$(id -g) /secure/streembit-keys

# Copy private keys to secure directory
cp registry/private/*.pem /secure/streembit-keys/

# Run container with mounted keys
docker run -d \
  --name streembit-blockchain \
  -e PRIVATE_KEY_PATH=/app/keys \
  -e ENABLE_COLLABORATOR=true \
  -e COLLABORATOR_NODES=streembit-limited-ie,streembit-foundation-us \
  -e COLLABORATOR_AUTO_START=true \
  -v /secure/streembit-keys:/app/keys:ro \
  -p 3000:3000 \
  -p 8333:8333 \
  streembit/blockchain:latest

Docker Environment Variables

# Required for collaborator nodes
ENV PRIVATE_KEY_PATH=/app/keys
ENV ENABLE_COLLABORATOR=true
ENV COLLABORATOR_NODES=node1,node2
ENV COLLABORATOR_AUTO_START=true

# Mount keys as read-only volume
VOLUME ["/app/keys"]

Security Benefits:

  • βœ… Private keys stay on host filesystem
  • βœ… Keys are mounted read-only to prevent modification
  • βœ… No keys embedded in Docker images or layers
  • βœ… Easy key rotation without rebuilding images
  • βœ… Supports different keys per environment

⚠️ Critical Notes:

  • Application will fail and exit if required private keys are missing
  • Use PRIVATE_KEY_PATH to specify custom key directory location
  • Ensure proper file permissions (600) on private key files
  • Keys must match the certificate paths in registry/accountable-nodes.json

Configuration

Configuration can be provided via:

  1. Configuration file (streembit.config.yaml)
  2. Environment variables (prefixed with STREEMBIT_)
  3. Command line arguments

Example Configuration

# streembit.config.yaml
node:
  port: 8333
  dataDir: "./data"
  network: "devnet"

api:
  enabled: true
  port: 3000
  cors: true

consensus:
  autoParticipate: false
  depositAmount: "100000"
  validationEnabled: true

# Collaborator settings
collaborators:
  enabled: true
  nodes: ["streembit-limited-ie", "streembit-foundation-us"]
  autoStart: true
  privateKeyPath: "./registry/private"  # Or "/app/keys" for Docker

logging:
  level: "info"
  file: "./logs/streembit.log"

Environment Variables

Key environment variables for collaborator configuration:

# Required for PoC consensus participation
ENABLE_COLLABORATOR=true
COLLABORATOR_NODES=streembit-limited-ie,streembit-foundation-us
COLLABORATOR_AUTO_START=true

# Private key location (critical for security)
PRIVATE_KEY_PATH=./registry/private

# Alternative paths for different deployments:
# PRIVATE_KEY_PATH=/secure/keys          # Production
# PRIVATE_KEY_PATH=/app/keys             # Docker
# PRIVATE_KEY_PATH=C:\secure\keys        # Windows

Development

Available Scripts

npm run build              # Build TypeScript to JavaScript
npm run dev                # Run in development mode
npm run test               # Run tests
npm run test:coverage      # Run tests with coverage
npm run lint               # Lint code
npm run lint:fix           # Fix linting issues
npm run format             # Format code with Prettier
npm run type-check         # Check TypeScript types

License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published