Fabric voteApp应用配置
下载voteApp源码
- git clone https://github.com/didianV5/voteApp.git
- chmod -R 777 voteApp
修改配置文件
- cd voteApp
- cd app
- vim ./startFabric.sh
- 修改其中一行的path为如下:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode install -n vote -v 1.0 -p /opt/gopath/src/github.com/vote
为链码添加依赖项
- cd /root/go/src/github.com/voteApp/chaincode
- go mod init
- GO111MODULE=on go mod vendor
安装node依赖包
- cd /root/go/src/github.com/voteApp/app
- npm install
- 如果失败,修改node版本:n 8.9.4
- 再次失败,尝试 npm rebuild
启动Fabric网络
- ./startFabric.sh
- 注册管理员:node enrollAdmin.js
- 注册用户:node registerUser.js
- 将当前目录下的hfc-key-store复制到/root/.hfc-key-store目录下:mv /root/go/src/github.com/voteApp/app/hfc-key-store/ /root/.hfc-key-store
启动项目
- node index.js
- 访问地址:http://ubuntu201:3000