A privacy-preserving federated-learning system secured by an Ethereum blockchain.
Clients train on disjoint MNIST shards, submit hashed model updates via Solidity smart contracts, and store both submissions and the aggregated global model on-chain.
- Git
- Docker & Docker Compose
- A local Ethereum network (we use Ganache CLI)
-
Clone the repo
git clone https://github.com/furk4neg3/FedChain.git cd FedChain -
Create your
.envSERVER_IP="XXX.XXX.XXX.XXX"
Find your IP via:
- Windows:
ipconfig - macOS/Linux:
ifconfigorhostname -I
- Windows:
-
Build & start everything
docker-compose up --build
- 🚨 Heads-up: The first build can take over 1 hour, as it builds images and runs 3 rounds of local training + global aggregation on MNIST.
- Local Training
- 3 clients each train a small CNN on their shard (C1: digits 0–2; C2: 3–6; C3: 7–9).
- Local accuracies: ~30 %, ~40 %, ~30 %.
- Submission
- Each client serializes its weights → computes a Keccak hash → calls
submitModel(hash, accuracy)on the smart contract.
- Each client serializes its weights → computes a Keccak hash → calls
- On-Chain Logging
- Solidity contract (on Ganache) logs
(round, client, hash, accuracy)in a new block.
- Solidity contract (on Ganache) logs
- Server Aggregation
- Flask+Web3.py service listens for submission events → fetches off-chain weights → runs Federated Averaging → ~85 % global accuracy → calls
updateGlobalWeights(...).
- Flask+Web3.py service listens for submission events → fetches off-chain weights → runs Federated Averaging → ~85 % global accuracy → calls
- Dashboard Updates
- Flask + Socket.IO pushes real-time charts (Chart.js) showing local vs. global accuracy and block/transaction metadata.
After the containers are up & training finishes, open:
open logs/report.htmlxdg-open logs/report.htmlstart .\logs\report.htmlHappy federating! 🤝🔒