在开发链上部署测试链码helloworld
- 利用 hyperledger/fabric-samples 进行部署
- 克隆 hyperledger/fabric-samples
git clone https://github.com/hyperledger/fabric-samples.git
- 克隆 hyperledger/fabric-samples
- 将链码文件夹 helloworld 复制到 fabric-samples/chaincode 下
- 到 fabric-samples 下
cd chaincode-docker-devmode
- 在 chaincode-docker-devmode 下打开三个终端
- 终端1-启动网络
docker-compose -f docker-compose-simple.yaml up
- 终端2-构建并启动链码
进入容器
到链码目录编译代码docker exec -it chaincode bash
运行链码cd helloworld go build
日志CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./helloworld
2018-08-25 03:58:31.237 UTC [shim] SetupChaincodeLogging -> INFO 001 Chaincode log level not provided; defaulting to: INFO 2018-08-25 03:58:31.237 UTC [shim] SetupChaincodeLogging -> INFO 002 Chaincode (build level: ) starting up ...
- 终端3-使用链码
进入容器
节点安装链码docker exec -it cli bash
节点实例化链码peer chaincode install -p chaincodedev/chaincode/helloworld -n mycc -v 0
验证peer chaincode instantiate -n mycc -v 0 -c '{"Args":["hi","jonluo"]}' -C myc
完成peer chaincode query -n mycc -c '{"Args":["get","hi"]}' -C myc peer chaincode invoke -n mycc -c '{"Args":["set", "hello", "world"]}' -C myc peer chaincode query -n mycc -c '{"Args":["get","hello"]}' -C myc