在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 一般 ...
随机推荐
- netfx_NativeCompilation.msi 传说中的 .NET Native 预览版的文件列表
卷 D 的文件夹 PATH 列表 卷序列号为 000000F6 CE0F:AB46 D:. │ LIST.TXT │ ├─12.0 │ └─Microsoft.Common.targets │ ├─I ...
- Ubuntu Desktop基本办公环境搭建
Ubuntu Desktop基本办公环境搭建 一如前面所强调的, linux系统是面向开发人员友好的,而对office办公人员并不友好 . 如果是重度的office办公需求人员,不建议使用linux ...
- Java提高篇(三八)-----Java集合细节(四):保持compareTo和equals同步
在Java中我们常使用Comparable接口来实现排序,其中compareTo是实现该接口方法.我们知道compareTo返回0表示两个对象相等,返回正数表示大于,返回负数表示小于.同时我们也知道e ...
- js函数实现转换css中常用的颜色编码
//转换css中常用颜色编码 var toRGB = function (val){ var reg1 = /^#([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i; ...
- Windows进程通信 -- 共享内存(1)
共享内存的方式原理就是将一份物理内存映射到不同进程各自的虚拟地址空间上,这样每个进程都可以读取同一份数据,从而实现进程通信.因为是通过内存操作实现通信,因此是一种最高效的数据交换方法. 共享内存在 W ...
- win7-VS2010-IIS网站的发布问题
前提:IIS配置已经完成 问题描述:我们在机房实验里,大家的都可以访问同学A发布的IIS网站,但是,A却不能访问我们每个人的网站,而我们也不能互相访问(除了A). 问题解决:忙乎了半天,原来A同学的防 ...
- IOS Socket 02-Socket基础知识
1. 简介 Socket就是为网络服务提供的一种机制 通信的两端都是Socket 网络通信其实就是Socket间的通信 数据在两个Socket间通过IO传输 2. Socket通信流程图 3. 模拟Q ...
- [Maven]Eclipse插件之Maven配置及问题解析.
前言:今天在自己环境装了Maven环境, 并且安装了Eclipse插件, 在查找插件过程中确实遇到一些问题, 好不容易找到一个 却又有问题.装好了插件之后, 用Eclipse创建Maven项目却出现 ...
- Atitit 团队建设的知识管理
Atitit 团队建设的知识管理 1.1. 要遵循"知识积累--创造--应用--形成知识平台--再积累--再创造--再应用--形成新的知识平台"的循环过程.1 1.2. 显性知识包 ...
- Android ListView 进阶学习
1.使用ListView展示数据结构为二维数组的数据 当我们遇到数据结构是二维数组的需求的时候,我们会首先想到ListView,但是要想实现二维数组,会想到ListView里面嵌套ListView,但 ...