blockchain-neu
FedCoin
Python

A Peer-to-Peer Payment System for Federated Learning

Last updated Mar 11, 2026
78
Stars
14
Forks
3
Issues
0
Stars/day
Attention Score
38
Language breakdown
Python 99.6%
Shell 0.4%
Files click to expand
README

FedCoin

A Peer-to-Peer Payment System for Federated Learning

Layered Architecture

  • Data (Transaction, Block, ChainStructure, etc.)
  • Network (Message, P2P, etc.)
  • Consensus (Consensus, PoSap, etc.)
  • Incentive
  • Contract
  • Application (Application, FedCoin, etc.)

Usage

Prepare

To build and run FedCoin, you must ensure the following software or package(s) are installed in your experimental computer(s):

Moreover, Linux distribution like Ubuntu 16.04.7 LTS is recommended as the operating system. Anaconda (Mirror: TUNA) is recommended as the environment manager. Run the conda create -n fedcoin python=3.5 tensorflow-gpu command, and the python -m pip install docker command in new created fedcoin environment could easily get a basic running environment.

Generate weights

Run the following codes in the Python environment to generate weights:

from blockchain.application.fedcoin import FedCoin FedCoin.runflserver()

Set parameters

Parameters are defined in blockchain/util/settings.py, which are showed as follows:

|Parameter|Description|Type|Range|Default| |:-------:|:----------|:--:|:---:|:-----:| |K|Number of FL clients|int|[2, inf]|20| |R|Number of replicas (miners)|int|[2, inf]|2| |D|Difficulty in mining|float|[0.0, inf]|1.5| |PRICE|Amount of FedCoins as rewards|float|[0.0, inf]|1000.0| |RUNTIME|Time to mine in a round|float|[0.0, inf]|15.0| |TRAIN_PRICE|Payments to the FL clients|float|[0.0, 1.0]|0.7| |COM_PRICE|Payments to the FL server for processing the model aggregation|float|[0.0, 1.0]|0.1| |SAP_PRICE|Payments yo the blockchain network miners for calculating SV|float|[0.0, 1.0]|0.2|

Note: The condition "TRAINPRICE + COMPRICE + SAP_PRICE = 1" should be satisfied.

Build and run

The shell code python main.py will build fedcoin and fedcoin_lw images, and run several fedcoin containers that matches the number of replicas defined in settings.

Run docker run fedcoin_lw will start publishing tasks.

The batch file clean.sh will stop and delete containers, as well as delete images that are untagged.

References

  • Yuan Liu, Zhengpeng Ai, Shuai Sun, Shuangfeng Zhang, Zelei Liu, Han Yu. FedCoin: A Peer-to-Peer Payment System for Federated Learning. In Book "Federated Learning: Privacy and Incentive" (DOI:10.1007/978-3-030-63076-8_9)
  • Yuan Liu, Shuai Sun, Zhengpeng Ai, Shuangfeng Zhang, Zelei Liu, Han Yu. FedCoin: A Peer-to-Peer Payment System for Federated Learning. In arXiv (arXiv:2002.11711)

© 2026 GitRepoTrend · blockchain-neu/FedCoin · Updated daily from GitHub