一 环境配置
1 新建目录workspace(非共享目录下)
在共享目录不支持符号链接,也就意味着无法在共享目录使用链接模块
mkdir workspace
2 下载marbel项目
git clone https://github.com/IBM-Blockchain/marbles.git --depth 1
3 下载Fabric-Samples
git clone https://github.com/hyperledger/fabric-samples.git
4 下载setup_script.sh
cd fabric-samples
5 执行setup_script.sh(下载较慢)
bash setup_script.sh
6 配置路径
export PATH=$PWD/bin:$PATH
二 启动fabcar网络
1 启动fabric网络
cd fabric-samples/fabcar
./startFabric.sh
2 验证网络是否启动
docker ps
3 更新node版本
sudo npm install -g n
sudo n stable
4 安装测试依赖关系(下载时间比较长)
npm install --unsafe-perm
5 注册用户
node enrollAdmin.js
node registerUser.js
node query.js
6 查看注册是否生成相关秘钥
cd hfc-key-store
7 更改hfc-key-store路径
cd ..
cp -r hfc-key-store/ ~ # 拷贝到根目录
cd ~
mv hfc-key-store/ /.hfc-key-store # 修改为隐藏文件
三 安装并实例化chaincode
1 安装相关node_modules
cd marbles
npm install –unsafe -perm
2 修改配置文件路径与安装路径一致
cd config
vim connection_profile_local.json
“credentialStore” :{
“path”: “/$HOME/.hfc-key-store”
}
“x-adminCert” :{
“path”: “/opt/gopath/src/github.com/work/fabric-samples/…
}
“x-adminKeyStore” :{
“path”: “/ opt/gopath/src/github.com/work/fabric-samples/…
}
3 安装链码
cd ..
cd scripts
node install_chaincode.js
4 实例化链码
node instantiate_chaincode.js
5 安装Gulp
cd ..
sudo npm install gulp -g
6 部署Marbel项目
gulp marbles_local
四 存在问题
1 Marble 项目部署不是在vagrant共享目录,如果部署在共享目录则需要更改符号链接(一般用npm install --no-bin-links,但并没有效果)
2 Virtualbox虚拟机网络使用的是NAT模式,主机不能通过网络访问到虚拟机,因此需要把虚拟机网络改成桥接模式。