开放代码社区 › RepChain 区块链平台

RepChain 区块链平台

开发工具JavaScript

RepChain 是一个采用 Scala 与 Akka 实现的开源许可链平台,具备数据、网络、共识、合约、API 与监控分层架构。支持 CFRD 共识、TLS 安全通信、gossip 组网、动态合约部署及 Restful 接口,适用于数字版权登记、可举证云存储等区块链应用开发与部署场景。

AI/机器学习Web后端前端工具部署/运维
作者:用户6868语言:JavaScript更新:2026-10-27
仓库地址
https://gitee.com/BTAJL/repchain.git

前往原仓库

README

# RepChain

RepChain官网:[https://repchain.net](https://repchain.net)

[RepChain文档](https://gitee.com/BTAJL/repchain/attach_files)   [单机多节点部署](https://1drv.ms/v/s!Aq4aIQBtXQ0-4U-gQwgS4nyBHM_w?e=MMqrZg)   [多机多节点部署](https://1drv.ms/v/s!Aq4aIQBtXQ0-4U7W8kDSffhXehY5?e=yJh0Ha)

## RepChain2.0免编译版本发布
- [RepChain免编译版本下载](https://github.com/RepChain-Group/repchain-package/releases) ——为方便用户使用,提供了免编译版本,此版本不需要编译即可直接运行
- 前置条件
  - 需要机器上安装java13,并配置好环境变量
  - 单机多节点解压后使用启动脚本 (start.sh或start.cmd),linux/mac使用start.sh,,win系统双击start.cmd
  - 多机多节点使用启动脚本(start01.sh至start05.sh或start01.cmd至start05.cmd),启动前需要修改配置文件

## 参考阅读
- [akka](https://akka.io/) ——系统内部模块采用akka actor实现
- [akka remoting security](http://doc.akka.io/docs/akka/current/scala/remoting.html) ——节点之间安全通信采用akka Remote支持的TLS
- [akka serialization](http://doc.akka.io/docs/akka/current/scala/serialization.html)——节点之间消息交互采用protobuf序列化
- [scalaPB](https://scalapb.github.io/)——从proto定义生成Scala类的工具
- [protobufjs](https://github.com/dcodeIO/ProtoBuf.js/)——在web端根据proto定义,反序列化protobuf字节流
- [swagger-scala](https://github.com/swagger-api/swagger-scala-module)——API支持Swagger UI
- [json4s](https://github.com/json4s/json4s)——在API层提供输入对象的json反序列化,返回结果的json序列化
- [d3.js-force layout](https://github.com/d3/d3-3.x-api-reference/blob/master/Force-Layout.md)——入/离网节点的自动布局
- [leveldb for java](https://github.com/dain/leveldb)——存取Blocks、Transactions索引
- [java security](http://docs.oracle.com/javase/8/docs/technotes/guides/security/index.html)——hash、签名、密钥对及证书管理均采用jdk内置方法

## 安装
- install [zuluJdk11+](https://www.azul.com/downloads/zulu-community/?&architecture=x86-64-bit&package=jdk)
- install [Python](http://www.python.org/downloads/)
- install [Scala](https://www.scala-lang.org/download/)
- install [SBT](http://www.scala-sbt.org/release/docs/Setup.html)
- install [Idea IDE](https://www.jetbrains.com/idea/download/#section=windows)
- install [keystore-explorer](http://keystore-explorer.org/) ——用于生成密钥对的工具,非必须
- install [protobuf editor](https://github.com/Enide/polyglot-maven-editors)——编辑protobuf定义工具,非必须

## 分层架构
![RepChain系统分层图](https://web-code-img.oss-cn-shanghai.aliyuncs.com/readme/b226b16226482b97a8e848a0.png)
- 数据层:负责数据格式定义,数据结构采用Protocol Buffers定义文件,并以此为基础实现数据的交换、验证、存储、读取及检索
- 网络层:采用JDK内置的TLS实现,支持入网许可验证,在此基础上进行去中心化的gossip组网,网络传播支持P2P和Pub/Sub两种方式
- 共识层:完成区块的输入共识和输出共识。采用兼顾实时性和安全性的CFRD算法,既照顾到交易的实时性要求,又能在一定程度防止节点串通作弊;输入共识对入块的交易顺序达成一致,输出共识对交易顺序执行的结果达成一致
- 合约层:为合约执行提供上下文环境,支持合约的动态部署、运行时加载和编译执行
- API层:提供外部接口,允许第三方应用以Restful的形式与系统交互,并允许开发者通过Swagger UI进行在线测试。API层提供交易签名提交、区块和交易检索等基本功能
- 监控层:在区块链网络中收集事件/日志,并将其以Protocol Buffers的格式推送至Web端,以H5图形技术进行实时状态的可视化展示和日志回放

## 运行
- ` 下载项目到本地`
  - git clone https://gitee.com/BTAJL/repchain.git
- `导入` 
  - 打开Idea IDE,File->New->Project or Project from VersionControl
  - 使用Idea的sbt插件导入
  - 使用sbt shell 进行compile
- 右键单击 rep.app.Repchain.scala,Run 'RepChain'(单机组网4个节点)
- 运行配置VM参数 -Dlogback.configurationFile=conf/logback.xml (使logback配置生效)
- 查看实时图 http://localhost:8081/web/g1.html
![实时状态图](https://web-code-img.oss-cn-shanghai.aliyuncs.com/readme/a9466af62a66f6a86108d0b0.gif) 
- 查看API  http://localhost:8081/swagger/index.html
![Swagger-UI](https://web-code-img.oss-cn-shanghai.aliyuncs.com/readme/6d073a465778f875d9b879dc.png)

## 修改配置
- 生成RepChain节点密钥对及信任证书列表(见[《RepChain开发者指南》](https://gitee.com/BTAJL/repchain/attach_files/235993/download) 2.1.5)
- 制作创世区块(见[《RepChain开发者指南》](https://gitee.com/BTAJL/repchain/attach_files/235993/download) 2.1.6)
- 调整系统配置参数(见[《RepChain开发者指南》](https://gitee.com/BTAJL/repchain/attach_files/235993/download) 2.1.7)

## 打包
- assembly 
  - 打包成jar包,进行分布式部署

## 示范应用
- [BAR](https://gitee.com/linkel/bar)(Base App of RepChain):提供了通用的基础功能实现,区块链应用实施者既可以直接复用其提供的功能, 也可以在其源代码的基础上进行开发,快速开发自己的DAppp
- [SBR](https://gitee.com/JayTsang/bar)(Storage Based on RepChain):基于BAR开发的可举证云存储应用示例
- [CRBB](https://gitee.com/linkel/CRBBV1.0)(Copyright Register Based on Blockchain):基于RepChain的数字版权登记保护应用示例