37

基于Hyperleger Fabric 华为BCS的区块链应用搭建(1)

 5 years ago
source link: https://studygolang.com/articles/13858?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

应用程序开发配置和构建

可以使用 Go 开发应用程序,并利用 Hyperledger Fabric SDK Go 中的可用 API 来调用链代码,以在区块链网络中完成事务处理。现阶段我们先运行测试项目。

步骤:

1、示例应用服务端代码运行

2、下载证书

3、构建证书目录

4、Fabric SDK配置

5、应用程序开发

6、应用程序配置

7、应用程序构建

步骤一:示例应用服务端代码运行

0、root用户配置

1、Go环境安装

资源下载

官网地址: https://golang.org/dl/

下载路径: https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz

加压到/usr/local/目录下:

tar -xvf /root/Downloads/go1.10.2.linux-amd64.tar.gz -C /usr/local/

配置环境变量 打开配置文件:

vim ~/.bashrc

填写如下内容:

export GOPATH=$HOME/go
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

永久生效:

source ~/.bashrc

检查安装结果

go

2、docker环境安装

# step 1: 安装必要的一些系统工具
apt update
apt -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装 Docker-CE
apt -y update
apt -y install docker-ce
# Step 5: 检查安装结果
docker version
# Step 6: 安装composer
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname - s)-$(uname -m) -o /usr/local/bin/docker-compose
# Step 7: 修改权限
chmod +x /usr/local/bin/docker-compose
# Step 8: 检查安装结果
docker-compose --version

3、示例代码下载

服务端:api-server.rar

前端镜像:portal.rar

注意

服务器文件解压完成后的目录结构。

5、第三方包安装

go get -u github.com/kardianos/govendor
go get -u github.com/astaxie/beego
go get -u github.com/beego/bee

6、运行api-server

运行 bee run api-server
VFzaemN.png!web

image.png

注意:

GOPATH下,项目文件放到

GOPATH/src目录下


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK