在开发链上部署测试链码helloworld
利用 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
完成
转载于:https://my.oschina.net/jonluo/blog/2999028