美文网首页
Hyperledger Composer 基础(1)

Hyperledger Composer 基础(1)

作者: 咦咦咦萨 | 来源:发表于2018-12-19 13:12 被阅读0次

IBM-Hyperledger Composer 基础,第 1 部分

在计算机上使用 Docker 运行 Playground

纯浏览器模式,使用docker安装

终端执行

docker run --name composer-playground --publish 8080:8080 hyperledger/composer-playground

latest: Pulling from hyperledger/composer-playground
4fe2ade4980c: Already exists
0ade4f5bae45: Pull complete
fd1dceaf77f3: Pull complete
3af60a5c027e: Pull complete
Digest: sha256:a49fbdcbb90dce6a708c866cc81f2966e8f0435c2a1c20ba89b35d1b82d131fb
Status: Downloaded newer image for hyperledger/composer-playground:latest
2018-12-19T02:29:32: PM2 log: Launching in no daemon mode
2018-12-19T02:29:32: PM2 log: App [composer-playground:0] starting in -fork mode-
2018-12-19T02:29:32: PM2 log: App [composer-playground:0] online
WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
2018-12-19T02:29:34.008Z INFO    :LoadModule               :loadModule()              Loading composer-wallet-filesystem from /home/composer/.npm-global/lib/node_modules/composer-playground/node_modules/composer-wallet-filesystem {}$
2018-12-19T02:29:34.034Z INFO    :PlaygroundAPI            :createServer()            Playground API started on port 8080 {}$

启动成功后,访问:http://127.0.0.1:8080

image.png

点击 “Let's Blockchain”

创建一个空的测试网络


image.png

修改网络名称为:test-network


image.png

选择一个空的网络模型,然后完成


image.png

连接网络


连接网络.png

添加文件


image.png

新增一个模型文件:


image.png image.png

源码为:

/**
 * New model file
 */

namespace org.acme.myfirstmodel

asset Test identified by testId {
    o String testId
    o String message
}

transaction Hello {
    --> Test test
}

再次添加一个Script File:


image.png

源码为:

/**
 * New script file
 */


/**
 * 以下注解是必须的
 */

/**
@param {org.acme.myfirstmodel.Hello} hello
@transaction
*/
function hello(hello){
    console.log("Hello: " + hello.test.message);
}

发布:


image.png

发布完成后,我们切换到“Test”标签,进行模型的测试:


image.png

创建一个资产:


image.png

修改testId和message,然后保存:


image.png

打开chrome浏览器的开发者调试窗口(WIN:F12),切换到Console标签:

image.png

提交测试交易:


image.png

测试成功:


image.png

测试完成后,需要清空chrome的缓存,才能重新开始:


image.png

其余部分,可跟随IBM教程完成。

相关文章

网友评论

      本文标题:Hyperledger Composer 基础(1)

      本文链接:https://www.haomeiwen.com/subject/rvvdkqtx.html