在IBM Bluemix上部署Hyperledger应用
简介
IBM Bluemix (http://www.ibm.com/bluemix)是一个基于cloud的应用开发和部署平台,提供包括多种服务和运行环境的支持。对Hyperledger应用开发者而言,IBM Bluemix提供免费的入门级区块运行环境。本文介绍了在IBM Bluemix上部署Hyperledger应用的基本过程。
第一步: 在 Bluemix中选择区块服务
登录Bluemix后,在Catalog页面中选择Application Services下的Blochain服务。

确认区块服务的名称,然后点击Create按钮以创建区块服务。

在新建的区块服务页面上点击LAUNCH按钮以启动区块服务,并显示其具体信息。


第二步: 在 Bluemix区块服务中注册用户
首先在区块服务页面中选择 APIs, 然后展开Network's Enroll IDs列表以获取预置的用户名和密码列表 。

然后向选定的区块节点发送如下请求以注册用户
POST https://e1bb641577f249a88acca04da0272249-vp3.us.blockchain.ibm.com:444/registrar
Content-Type: application/json
{
"enrollId": "admin",
"enrollSecret": "19725f3d88"
}
注册成功的响应为
{
"OK": "Login successful for user 'admin'."
}
第三步: 在 Bluemix区块服务中发布应用代码, 前提是应用的GoLang代码必须在github.com上。
POST https://e1bb641577f249a88acca04da0272249-vp3.us.blockchain.ibm.com:444/chaincode
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "https://github.com/huyouhengbc/Hyperledger/HelloWorld"
},
"ctorMsg": {
"function": "init",
"args": [
]
},
"secureContext": "admin"
},
"id": 1
}
发布成功的响应为
{
"jsonrpc": "2.0",
"result": {
"status": "OK",
"message": "e2623e76371a16ca86d97bfb90bdab95885939bf4f2fa40133d65bca4aace27eaf94d8cd10438b80de097442916f6bfef87fb45a6cd678e3cb6ec0bd8dd008c2"
},
"id": 1
}
第四步: 测试应用代码,
Query请求
POST https://e1bb641577f249a88acca04da0272249-vp3.us.blockchain.ibm.com:444/chaincode
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "query",
"params": {
"type": 1,
"chaincodeID": {
"name": "e2623e76371a16ca86d97bfb90bdab95885939bf4f2fa40133d65bca4aace27eaf94d8cd10438b80de097442916f6bfef87fb45a6cd678e3cb6ec0bd8dd008c2"
},
"ctorMsg": {
"function": "hello",
"args": [
]
},
"secureContext": "admin"
},
"id": 3
}
Query响应
200 OK
access-control-allow-headers: accept, content-type
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sun, 30 Oct 2016 05:13:58 GMT
Content-Length: 73
Server: nghttpx nghttp2/1.14.0-DEV
Via: 1.1 nghttpx
X-Firefox-Spdy: h2
{"jsonrpc":"2.0","result":{"status":"OK","message":"Hello World"},"id":3}
Invoke请求
POST https://e1bb641577f249a88acca04da0272249-vp3.us.blockchain.ibm.com:444/chaincode
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "invoke",
"params": {
"type": 1,
"chaincodeID": {
"name": "e2623e76371a16ca86d97bfb90bdab95885939bf4f2fa40133d65bca4aace27eaf94d8cd10438b80de097442916f6bfef87fb45a6cd678e3cb6ec0bd8dd008c2"
},
"ctorMsg": {
"function": "hello",
"args": [
]
},
"secureContext": "admin"
},
"id": 3
}
Invoke响应
200 OK
access-control-allow-headers: accept, content-type
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sun, 30 Oct 2016 05:13:22 GMT
Content-Length: 98
Server: nghttpx nghttp2/1.14.0-DEV
Via: 1.1 nghttpx
X-Firefox-Spdy: h2
{"jsonrpc":"2.0","result":{"status":"OK","message":"d74495ff-f3d3-44ba-acc6-5fbc767bbf21"},"id":3}
后记
- 发布应用代码中的path指向的是GoLang代码所在的目录,而不是GoLang源码文件, 错误响应如下:
POST https://e1bb641577f249a88acca04da0272249-vp0.us.blockchain.ibm.com:444/chaincode
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "https://github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go"
},
"ctorMsg": {
"function": "init",
"args": [
]
},
"secureContext": "user_type8_0"
},
"id": 1
}
-- response --
200 OK
access-control-allow-headers: accept, content-type
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sun, 30 Oct 2016 04:00:14 GMT
Content-Length: 721
Server: nghttpx nghttp2/1.14.0-DEV
Via: 1.1 nghttpx
X-Firefox-Spdy: h2
{"jsonrpc":"2.0","error":{"code":-32001,"message":"Deployment failure","data":"Error when deploying chaincode: Error getting chaincode package bytes: Error getting code 'go get' failed with error: 'exit status 1'\npackage github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go: cannot find package 'github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go' in any of:\n\t/usr/local/go/src/github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go (from $GOROOT)\n\t/go/_usercode_/234208637/src/github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go (from $GOPATH)\n\t/go/src/github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go\n"},"id":1}
- Bluemix提供基于基于Hyperledger Fabric v0.5的服务,如果使用最新的Hyperledger Fabric接口, 发布应用时错误响应如下:
{
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "Deployment failure",
"data": "Error when deploying chaincode: Error getting chaincode package bytes: Error getting code 'go get' failed with error: 'exit status 2'\n# github.com/huyouhengbc/Hyperledger/HelloWorld\n/go/_usercode_/730749822/src/github.com/huyouhengbc/Hyperledger/HelloWorld/HelloWorld.go:15: undefined: shim.ChaincodeStubInterface\n/go/_usercode_/730749822/src/github.com/huyouhengbc/Hyperledger/HelloWorld/HelloWorld.go:21: undefined: shim.ChaincodeStubInterface\n/go/_usercode_/730749822/src/github.com/huyouhengbc/Hyperledger/HelloWorld/HelloWorld.go:27: undefined: shim.ChaincodeStubInterface\n"
},
"id": 1
}
- 发布应用报错
{
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "Deployment failure",
"data": "Error when deploying chaincode: Failed loading TCerts from TCA"
},
"id": 1
}
解决方法: 在 Demo Chaincoded下发布示例应用,选择Show API details输出中使用的节点。
总结
本文介绍了在IBM Bluemix上部署Hyperledger应用的基本过程。
在IBM Bluemix上部署Hyperledger应用的更多相关文章
- Eclipse上开发IBM Bluemix应用程序
林炳文Evankaka原创作品. 转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要解说了怎样使用安装EclipseIBM Bluemix插件.并在Eclipse ...
- 基于IBM Bluemix的数据缓存应用实例
林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:IBM® Data Cache for Bluemix 是快速缓存服务.支持 Web 和 ...
- 使用 Bluemix™ Live Sync 高速更新 Bluemix 上执行的应用程序实例
假设您要构建 Node.js 应用程序,那么能够使用 IBM® Bluemix® Live Sync 高速更新 Bluemix 上的应用程序实例,并像在桌面上进行操作一样进行开发,而无需又一次部署.执 ...
- IBM Bluemix体验:Containers
国际版的Bluemix目前有三个region,US South,United Kingdom和Sydney.其中US South是功能最全的,UK其次,Sydney功能最少.Containers服务在 ...
- fedora上部署ASP.NET——(卡带式电脑跑.NET WEB服务器)
andrew,20130601,guilin 本文记录在树莓派(fedora)上部署ASP.NET MVC2 的过程. 本文共分为六部分,分别是前置条件,Apache的安装,Mysql的安装,安装mo ...
- CentOS 7 上部署Mono 4 和Jexus 5.6
概述 在这篇文章中我们将讨论如何在CentOS 7操作系统,安装 jexus. mono 和 配置 jexus,因此它将能够在这种环境中运行一个asp.net mvc 4 应用.这篇文章是描述如何在 ...
- deepsooncms在Ubuntu 14.04上部署教程
deepsooncms在Ubuntu 14.04上部署教程 一.安装mono1.在命令行运行sudo apt-key adv --keyserver keyserver.ubuntu.com --re ...
- 基于Kubernetes在AWS上部署Kafka时遇到的一些问题
作者:Jack47 转载请保留作者和原文出处 欢迎关注我的微信公众账号程序员杰克,两边的文章会同步,也可以添加我的RSS订阅源. 交代一下背景:我们的后台系统是一套使用Kafka消息队列的数据处理管线 ...
- 在 CentOS7 上部署 MySQL 主从
在 CentOS7 上部署 MySQL 主从 通过 SecureCRT 连接至 MySQL 主服务器: 找到 my.cnf 文件所在的目录: mysql --help | grep my.cnf 一般 ...
随机推荐
- ORACLE 自定义分页存储过程
一.创建包 CREATE OR REPLACE PACKAGE PKG_JK_LAB_BASIC IS TYPE CURSOR_TYPE IS REF CURSOR; PROCEDURE SP_GET ...
- .Net Core CLI在CentOS7的安装及使用简介
1. 安装libunwind cd /usr/local/src wget http://download.savannah.gnu.org/releases/libunwind/libunwind- ...
- 使用curl 下载HTML
简单的一个curl小例子: #include <iostream> #include <string> #include <sstream> #include &l ...
- Java虚拟机10:类加载器
类与类加载器 虚拟机设计团队把类加载阶段张的"通过一个类的全限定名来获取此类的二进制字节流"这个动作放到Java虚拟机外部去实现,以便让应用程序自己决定如何去获取所需要的类.实现这 ...
- 作业七:团队项目——Alpha版本冲刺阶段-07
昨天进展:代码编写. 今天安排:代码编写.
- 阿里巴巴B2B搜索学习
1.搜索业务 主搜索:商品搜索.商家搜索.采购搜索.app搜索 行业搜索:淘货源.淘工厂.聚好货.主题市场.品牌馆等 2.优势 由于用户多,需求强烈,收益大,所以功能.场景.架构做到极致高效. 代码复 ...
- IOS Socket 04-利用框架CocoaAsyncSocket实现客户端/服务器端
这篇文章,我们介绍CocoaAsyncSocket框架的使用,主要介绍实现客户端/服务器端代码,相信在网上已经很多这样的文章了,这里做一下自己的总结.这里介绍使用GCD方式 一.客户端 1.下载地址 ...
- 我心中的核心组件(可插拔的AOP)~第十三回 实现AOP的拦截组件Unity.Interception
回到目录 说在前 本节主要说一下Unity家族里的拦截组件,对于方法拦截有很多组件提供,基本上每个Ioc组件都有对它的实现,如autofac,它主要用在orchard项目里,而castle也有以拦截的 ...
- Atitit 跨平台异常处理(2)--------异常转换 -----java c# js异常对象结构比较and转换
Atitit 跨平台异常处理(2)--------异常转换 -----java c# js异常对象结构比较and转换 { "@type":"java.lang.Runti ...
- VS2012 MVC4 学习笔记-概览
1. 访问请求过程 访问收到后路由(Router)根据路径由分配给对应的控制器(Control),然后由控制器返回页面视图(View) 路由设置一个默认的控制器,类似 主页的样子吧 <未完待续& ...