Refactored P2P classical blockchain scaffold with quantum-ready hooks. This page is your copy-paste guide for local and multi-machine runs, troubleshooting, and next steps.
This codebase separates core data models, P2P networking, mining, and the main node CLI.
Status: networked classical PoW demo works; ~50% toward full feature set.
python -m venv venv5000, 5001, 5002...)pyenv.pkg install python clang git; paths like /data/data/com.termux/files/home.
# 1) Clone your repo
git clone <YOUR_REPO_URL> Quantum-Blockchain-Project
cd Quantum-Blockchain-Project
# 2) Create & activate venv
python -m venv venv
# macOS/Linux
source venv/bin/activate
# Windows PowerShell
# .\venv\Scripts\Activate.ps1
# 3) Install deps (Flask, requests, etc.)
pip install -U pip wheel
pip install flask requests ecdsa
# 4) (Optional) For quantum worker later
# pip install qiskit qiskit-ibm-runtime python-dotenv fastapi uvicorn
# from project root
python src/main_blockchain.py 5000
# CLI appears; try commands: mine, tx, chain, peers, sync, help
Open a second terminal:
# terminal 1
python src/main_blockchain.py 5000
# terminal 2 (connect to node1 as peer)
python src/main_blockchain.py 5001 127.0.0.1:5000
After mining on one node, run sync on the other; hashes should match.
5000) and run:
python src/main_blockchain.py 5000
# macOS/Linux:
ip addr # or: ifconfig
# Windows:
ipconfig
# Example: Machine A is 192.168.1.50
python src/main_blockchain.py 5001 192.168.1.50:5000
sudo ufw allow 5000/tcpMost nodes expose simple JSON endpoints via Flask. From another terminal:
# Get peers
curl -s http://127.0.0.1:5000/peers | jq .
# Get chain summary
curl -s http://127.0.0.1:5000/chain | jq .
# Broadcast a transaction (example payload)
curl -s -X POST http://127.0.0.1:5000/tx \
-H "Content-Type: application/json" \
-d '{"to":"ADDR_ABC123","amount":5.0}' | jq .
curl http://HOST_IP:5000/peersHOST_IP:PORT (no protocol prefix).sync on the out-of-date node.difficulty and validation rules.Set-ExecutionPolicy RemoteSigned.\venv\Scripts\Activate.ps1known_peers.json) + periodic gossip.quantum_miner.mine(target) that can call IBM Q via your quantum-worker FastAPI.oqs-python) for post-quantum signatures./status & /chain to visualize height, peers, and last hash.If/when you connect IBM Quantum, run your quantum-worker FastAPI separately and set credentials via .env:
# .env (example)
IBM_QUANTUM_API_KEY=YOUR_IBM_TOKEN
IBM_QUANTUM_INSTANCE=ibm-q/open/main
QWORKER_URL=http://127.0.0.1:8000
# run the worker
uvicorn quantum-worker.main:app --host 0.0.0.0 --port 8000 --reload
In quantum_miner.py, post to ${QWORKER_URL}/qrng or /poq/start and embed job_id + resultHash in your block header for on-chain verification.
© Quantum-Blockchain Project • This HTML README is safe to host as docs. Update commands/paths to match your repo layout.