using Hyperledger fabric source code to emulate the IBM Bluemix Blockchain Service in the Win7 environmentTags: blockchain block chain2016-10-13 07:05 949 people read Comments (1) favorite reports Classification:Blockchain (a)Docker (5)Blockchain (6)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Directory (?) [+]
Using Hyperledger/fabric source code to emulate IBM Bluemix Blockchain service authors in Win7 environments: Chan Siu Lun
Email:[email protected] When the United States Federal Reserve Chairman Yelenli the Blockchain (blockchain), the blockchain, like wildfire, swept the whole Earth, it will change the traditional human life habits; the only IBM Bluemix offers Bloclcahain service recently almost stuffed to explode, often appear the use of excess load of information, fortunately, IBM Buddha heart provides 40,000 lines Hyperledger/fabric source code without these source code, The application of the blockchain will be controlled by a deep pocket manufacturer, so long as the enterprise can develop its own blockchain application system in support of the Docker cloud platform, interested enterprises can contact the joint development of private communication. The following example is the ability to emulate the IBM Bluemix Bloclcahain service with Hyperledger/fabric source code in local machine, which means that you do not have to log on to IBM Bluemix to perform the IBM Provides examples of blockchain marbles. Open environment: Win7 (>=8g, RAM), vagrant, Blockchain, docker,golang1. Win7 mounting Cygwin (https://cygwin.com/install.html)
Set the installed executable directory (C:\cygwin64\bin) to the console system path variable
Win7 installation VirtualBox (Virtualbox-5.1.6-110634-win.exe) (https://www.virtualbox.org/)
Win7 Installing Git (https://git-scm.com/downloads)
2. Create a GitHub account
Log in to GitHub to create an account (https://github.com/records username and password)
Fork Hyperledger/fabric
Browser into the following URL:
Https://github.com/hyperledger/fabric/blob/master/docs/Gerrit/gerrit.md#Working-with-a-local-clone-of-the-repository
(Tap Fork)
3. Verify that the fabric is installed to your Guthub repository,
4. Clone xxxxxx/fabric to Win7 Local machine
Enter Win7 command shell:
$mkdir-P d:\GoProjects\src\github.com\hyperledger$cd d:\GoProjects\src\github.com\hyperledger$git clone https:// GITHUB.COM/XXXXXXX/FABRIC$CD d:\GoProjects\src\github.com\hyperledger\fabric\devenv
Fix Vagrantfile (D:\GoProjects\src\github.com\hyperledger\fabric\devenv)
New:
Config.vm.network "Forwarded_port", guest:22, host:22
Config.vm.network "Forwarded_port", guest:3000, host:3000
$vagrant up (it takes a while to create a virtual machine Hyperledger the first time)
5. Log in to the Hyperledger VM using Putty (Appendix 1)
(username:vagrant,password:vagrant)
6. Install node latest version in Hyperledger VM using NVM (see Appendix 2) $ NVM use 6.7.0 (select node version) $ node-v
v6.7.0
$ npm-v
3.10.3
7. Verify that the Hyperledger is mounted on the Win7 directory
Hyperledger mount point ($GOPATH/src/github.com/hyperledger/fabric)
Mounted Win 7 Local machine directory (d:\GoProjects\src\github.com\hyperledger\fabric)
Add empty file (for example, touch ABCD) test with touch command to mount successfully
8. Download the edited Marbles sample related file
Installing the Marbles sample to Local machine (https://github.com/IBM-Blockchain/marbles)
Cdgopath/src/github.com/hyperledger/fabric$ git clone https://github.com/ibm-blockchain/marbles.git$ CD marbles
App.js in Appendix 3, Mycreds.json overwrites the original file, as it does not use Bluemix blockchain
Service, you must use the Hyperledger Chaincode to first fork the Marbles-chaincode to
My repository, then clone to Hyperledger VM, modify the following file:
(*shim. Chaincodestub Fix shim. Chaincodestubinterface)
Https://github.com/chenlin2/marbles-chaincode/tree/master/hyperledger/part1/part1_chaincode.go
Https://github.com/chenlin2/marbles-chaincode/tree/master/hyperledger/part2/part2_chaincode.go
Change and then back to my GitHub repository. The following app.js contain Zip_url,git_url
Fixed to Chenlin2/marbles-chaincode (system default is not available, user can attempt to use
Own GitHub repository)
Ibm-blockchain/marbles-chaincode Fork to User repository
Marbles-chaincode Download the Chaincode uploaded by Hyperledger vm after modification
9. Set up node Vp0,vp1 in the Hyperledger VM (putty to reopen another terminal) mkDirgopath/src/github.com/hyperledger/fabric/vagrant_marbles Cdgopath/src/github.com/hyperledger/fabric/vagrant_marbles$ docker Pull hyperledger/fabric-baseimage:x86_64-0.1.0$ Docker images (record image id:db53d04b117c) $ docker Tag db53d04b117 C hyperledger/fabric-baseimage:latest (change tag) $ docker images (verify hyperledger/fabric-baseimage:latest)
$ vi Docker-compose.yaml (edit Docker-compose.yaml as Attachment 3) $ docker-compose up (process requires hyperledger/fabric-baseimage:latest)
10 Execution Marbles Example (another terminal) Cdgopath/src/github.com/hyperledger/fabric/marbles$sudo npm Install gulp-g (Installing the Gulp kit)
$sudo npm Install (installs dependences according to Package.json in the Node modules folder)
Execute the $gulp above without errors (perform the work defined in Gulpfile.js)
SUDONPMINSTALL(If The mistake of sending the wrong is to practice the line Node App.js)
if (gulp or node App.js) executes the following error, repeat the instruction (with RAM size
Please close the unnecessary program in the window)
If execution succeeds, the following screen appears
11. Browser input http://localhost:3000, click CREATE (each step represents transaction)
12. Select the color, size, user = = Create
13. Drag Bob's marble to Leroy ' s
14. Drag the Red Mable to the Trash
15. Browser Input HTTP://LOCALHOST:3000/P2, (2 peer) Click CREATE
Bob 及 Leroy 可建立自己的 marble 并拖曳至另不同 user, 且user可以所持 marble 交易不同颜色的 marble。
16. Specify that User is bob to drag white marble to Leroy ' s (not bob cannot drag)
17. Under BOB Click Trade (Trading marbles use)
18. Select a Trading object
19. Show pending trades, click X (delete pending trades)
20. Pending transactions will disappear
If you drag Bob's red marble to the trash, the pending deal disappears.
21. This example can be modified to capture the treasure game
a 可增加参与者人数 ( 2 -> 5)b 建立宝藏库, marble可改为宝物, 每一种宝物都有不同颜色组合, 根据 user所付出劳务的多寡,可至宝藏库换得不同价值的宝物.相同宝物不同颜色全拿,可至宝藏库交换更高价值的宝物,也可与其它参与者交换。c 参予者不积极参与游戏,先前的宝物,将自动退还至宝藏库,积极度的计算与目前所获宝物价值有关,所获宝物愈多,积极度愈严格 (一定时间未取得相对应。d 等级宝物就需退回原有取得之宝物;当所有宝物都被退回,即中止该user 参与取宝游戏)。
22. Treasure game can be used in advertising agencies, the user can see the amount of advertising as labor expenses, after winning the champion may be paid to agents cash as compensation; games are independent of individual abilities; User can get paid only if they take the time to see the ads. Appendix:
1.win7 Installation Putty
Http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
http://download.ithome.com.tw/article/index/id/1649
2.hyperledger VM Installation NVM & node
http://www.liquidweb.com/kb/how-to-install-nvm-node-version-manager-for-node-js-on-ubuntu-14-04-lts/
https://www.liquidweb.com/kb/how-to-install-node-js-via-nvm-node-version-manager-on-ubuntu-14-04-lts/
3.docker-compose.yaml, App.js, Mycreds.json
Https://1drv.ms/u/s!AkBmzWP0h-VxghFdrcW_nVX1GpgO
4. Chen Zhaolin Facebook
https://zh-cn.facebook.com/chaolin.chen.18
Participation in the text:
1.https://github.com/chenlin2/marbles2/blob/master/local_blockchain.md
2.http://www.wealth.com.tw/article_in.aspx?nid=8450
3.https://github.com/hyperledger/fabric/blob/master/docs/dev-setup/devenv.md
4.https://github.com/diegomasini/hyperledger-fabric/blob/master/docs/dev-setup/devnet-setup.md
5.https://github.com/ibm-blockchain/marbles
6.https://github.com/ibm-blockchain/learn-chaincode
7.https://github.com/hyperledger/fabric/blob/master/docs/setup/network-setup.md
8.https://console.ng.bluemix.net/docs/services/blockchain/ibmblockchain_tutorials.html
9.https://1drv.ms/b/s!akbmzwp0h-vxggckd76dvulz92ky
10.https://1drv.ms/f/s!akbmzwp0h-vxbr7h1utnstmcpwi
11.https://1drv.ms/b/s!akbmzwp0h-vxazobosvz8ngmlpm
12.https://1drv.ms/b/s!akbmzwp0h-vxblk7fojh9il5hhc
13.https://www.youtube.com/watch?v=24jaf9eu1mk&list=uuotze-b_je_ovy9k9uhz4ba&index=74
14.https://www.youtube.com/watch?v=wsmj-rwuo8i&list=uuotze-b_je_ovy9k9uhz4ba&index=73
Using Hyperledger fabric Source code to emulate the IBM Bluemix Blockchain Service in the Win7 environment