A professional blockchain platform built with PHP 8+, featuring Proof of Stake consensus, smart contracts, advanced synchronization systems, and enterprise security.
- Proof of Stake Consensus - Energy-efficient consensus mechanism
- Smart Contracts - EVM-compatible virtual machine
- Advanced Cryptography - secp256k1, ECDSA, Keccak-256
- High Performance - 1000+ transactions per second
- Fast Sync - 10x faster synchronization with state snapshots
- Light Client - 92% storage reduction with SPV verification
- Checkpoint Sync - Instant bootstrapping from trusted checkpoints
- Mobile Optimized - Efficient sync for resource-constrained devices
- Hardware Security Module - Professional key management
- Multi-signature Support - Enhanced transaction security
- Rate Limiting - DDoS protection
- Secure Storage - AES-256 encryption
- RESTful API - Complete blockchain interaction API
- CLI Tools - Command-line interface for operations
- Web Explorer - Built-in blockchain explorer
- Comprehensive Tests - Full test coverage
- PHP 8.0 or higher with the following extensions:
- OpenSSL (for cryptographic operations)
- cURL (for network communications)
- JSON (for data serialization)
- mbstring (for string manipulation)
- MySQLi or PDO (for database operations)
- Composer (dependency management)
- MySQL 8.0+ or MariaDB 10.4+ (optional, for persistent storage)
- Redis (optional, for caching and session storage)
- Git (for version control)
- Docker & Docker Compose (optional, for containerized deployment)
- Node.js 16+ (optional, for frontend tools)
- Web server (Apache/Nginx)
- SSL certificate (for HTTPS)
- Firewall configuration (ports 8545, 8546)
- Backup solution (for blockchain data)
# Clone the repository
git clone https://github.com/infosave2007/phpblockchain.git
cd phpblockchain
# Install dependencies (simplified - works without database extensions)
composer install --ignore-platform-req=ext-mysqli --ignore-platform-req=ext-pdo_mysql --ignore-platform-req=ext-gmp --no-dev
# Alternative: Install with development tools
# composer install --ignore-platform-req=ext-mysqli --ignore-platform-req=ext-pdo_mysql --ignore-platform-req=ext-gmp
# Copy environment configuration
cp .env.example config/.env
# Set proper permissions
chmod +x server.php cli.php crypto-cli.php check.php
chmod -R 755 storage/ logs/
# Create required directories
mkdir -p storage/blocks storage/state storage/cache
mkdir -p logs/blockchain logs/transactions
# Run system check
php check.php
# Initialize configuration (optional - use web installer instead)
php cli.php init --network="My Network" --symbol="MBC"
# Blockchain Configuration
BLOCKCHAIN_NETWORK=mainnet
BLOCKCHAIN_SYMBOL=MBC
CONSENSUS_ALGORITHM=pos
BLOCK_TIME=10
INITIAL_SUPPLY=1000000
# Database Configuration
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=blockchain
DB_USERNAME=blockchain_user
DB_PASSWORD=your_secure_password
# Network Configuration
MAX_PEERS=25
# Security
API_KEY=your_secure_api_key_32_chars_min
ADMIN_EMAIL=admin@yourdomain.com
RATE_LIMIT_ENABLED=true
http://localhost:xxxx/web-installer/
#### Manual Database Setup
```sql
CREATE DATABASE blockchain;
CREATE USER 'blockchain_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON blockchain.* TO 'blockchain_user'@'localhost';
FLUSH PRIVILEGES;
# Run tests
php test.php
# Start the demo
php demo.php
# Professional unit tests
./vendor/bin/phpunit
# Check system status
php cli.php status
<?php
require_once 'vendor/autoload.php';
use Blockchain\Core\Cryptography\KeyPair;
use Blockchain\Core\Transaction\Transaction;
use Blockchain\Core\Blockchain\Block;
// Generate keypairs
$alice = KeyPair::generate();
$bob = KeyPair::generate();
// Create transaction
$transaction = new Transaction(
$alice->getPublicKey(),
$bob->getPublicKey(),
100.0,
0.1
);
// Create block
$block = new Block(1, [$transaction], 'previous_hash', time());
echo "Block hash: " . $block->getHash() . "\n";
Feature | Performance |
---|---|
Transaction Processing | 1,000+ tx/sec |
Block Validation | 10+ blocks/sec |
Sync Speed (Fast) | 10x improvement |
Storage (Light Client) | 92% reduction |
Memory Usage | < 10MB |
βββ core/
β βββ Blockchain/ # Blockchain core logic
β βββ Cryptography/ # Cryptographic functions
β βββ Consensus/ # Proof of Stake implementation
β βββ Transaction/ # Transaction processing
β βββ SmartContract/ # Smart contract VM
β βββ Sync/ # Advanced synchronization
β βββ Security/ # Security features
βββ api/ # REST API
βββ wallet/ # Wallet management
βββ tests/ # Test suite
βββ examples/ # Usage examples
- secp256k1 Elliptic Curve Cryptography
- ECDSA Digital Signatures
- Keccak-256 Cryptographic Hashing
- Secure Key Generation and Storage
- Multi-signature Transaction Support
- Hardware Security Module Integration
- Downloads state snapshots
- 10x faster than full sync
- Validates recent blocks only
- Downloads block headers only
- SPV verification with Merkle proofs
- 92% storage reduction
- Bootstraps from trusted checkpoints
- Instant network joining
- Suitable for new nodes
# Run all tests
./vendor/bin/phpunit
# Run simple tests
php test.php
# Run performance demo
php demo.php
# Fix file permissions
chmod -R 755 storage/ logs/
chown -R www-data:www-data storage/ logs/ # Linux/Ubuntu
chown -R _www:_www storage/ logs/ # macOS
# Ubuntu/Debian
sudo apt-get install php-openssl
# CentOS/RHEL
sudo yum install php-openssl
# macOS
brew install openssl
# Ubuntu/Debian
sudo apt-get install php-mysqli php-pdo-mysql php-gmp
# CentOS/RHEL
sudo yum install php-mysqli php-pdo php-gmp
# macOS
brew install php-gmp
# Alternative: Install without database extensions
composer install --ignore-platform-req=ext-mysqli --ignore-platform-req=ext-pdo_mysql --ignore-platform-req=ext-gmp
# Update Composer
composer self-update
# Clear cache
composer clear-cache
# Install with increased memory
php -d memory_limit=2G composer install
# Test database connection
php cli.php db:test
# Create database manually
mysql -u root -p -e "CREATE DATABASE blockchain;"
# If you get GitHub authentication errors during installation
composer clear-cache
rm -rf vendor/ composer.lock
# Use the simplified installation
composer install --ignore-platform-req=ext-mysqli --ignore-platform-req=ext-pdo_mysql --ignore-platform-req=ext-gmp --no-dev
POST /api/transaction
{
"from": "public_key",
"to": "public_key",
"amount": 100.0,
"fee": 0.1
}
GET /api/block/{hash}
GET /api/balance/{address}
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
docker-compose up -d
# Configure web server to point to index.php
# Set proper permissions
chmod +x server.php
php server.php
- Layer 2 scaling solutions
- Cross-chain interoperability
- Advanced governance features
- Mobile wallet applications
- Enterprise integration tools
- GitHub Issues: Report bugs
- Documentation: Wiki
Built with β€οΈ using PHP 8+ and modern blockchain technologies