Super Ledger (i) Hyperledger Fabric environment

Source: Internet
Author: User
Tags curl git clone docker for mac docker ps hyperledger fabric


I. Concepts

Hyperledger is a umbrella project of open source Blockchains and related tools, started in December 2015 by the Linux Foundation, to support the collaborative development of blockchain-based ledgers.

Hyperledgerfabric is a subproject based in Openblockchain denoted by IBM.

Hyperledger Fabric is a platform for distributed ledger solutions, underpinned from a modular architecture delivering high D Egrees of confidentiality, resiliency, flexibility and scalability.

Hyperledger Fabric is designed to support pluggable implementations of different components, and accommodate the Complexi Ty and intricacies that exist across the economy ecosystem.

Hyperledger Fabric delivers a uniquely elastic and extensible architecture, distinguishing it from alternative blockchain Solutions.  Planning for the future of enterprise blockchain requires to top of a building, open source fully-vetted; Hyperledger Fabric is your starting point.


two. HelloWorld

1. Setup Docker for Mac

reference:http://blog.csdn.net/jiangmengya1/article/details/79354256


2. Download Hyperledger:

# git clone https://github.com/hyperledger/fabric.git


3. Download Docker Images

Enter Directory fabric/scripts:

# CD .../fabric/scripts/

Modify Bootstrap script:

# chmod  _x  bootstrap-1.0.0.sh
# sed-i '  s/curl/#curl/g '  bootstrap-1.0.0.sh

Download Images:

#./bootstrap-1.0.0.sh

Show the images downloaded:

# Docker Images



4. Download Hyperledger Samples:

git clone https://github.com/hyperledger/fabric-samples.git


5. Launch:

Enter Directory Fabric-samples/basic-network:

# CD fabric-samples/basic-network/

Launch container using Docker-compose:

# docker-compose-f Docker-compose.yml up-d

Check it:

# docker PS

We can something like this:



6. Demo:

# Switch the environment to the Administrator user's MSP and enter the peer node container peer0.org1.example.com
Docker exec-it-e "Core_peer_mspconfigpath=/etc/hyperledger/msp/users/admin@org1.example.com/msp" Peer0.org1.example.com Bash

# Create Channel
Peer channel Create-o orderer.example.com:7050-c mychannel-f/etc/hyperledger/configtx/channel.tx

# Join the Aisle
Peer Channel Join-b Mychannel.block

# Exit Peer node container peer0.org1.example.com
Exit

#退出Peer节点容器peer0. org1.example.com, enter the CLI container to install the chain code and instantiate:
# into the CLI container
Docker exec-it Cli/bin/bash

# Install chain code for peer node peer0.org1.example.com
Peer Chaincode install-n mycc-v v0-p github.com/chaincode_example02

# Instantiate chain code
Peer Chaincode instantiate-o orderer.example.com:7050-c mychannel-n mycc-v ' {v0-c ': ["Init", "a", "M", "B", "200"] }'

# Query Initial value
# Display Results: Query result 100 and query outcome 200
Peer Chaincode query-c mychannel-n mycc-v ' {v0-c ': [' query ', ' A ']} '
Peer Chaincode query-c mychannel-n mycc-v ' {v0-c ': [' query ', ' B ']} '

# Transfer from a 10 to B
# Display Results:
Peer Chaincode invoke-c mychannel-n mycc-v ' {v0-c ': ["invoke", "a", "B", "10"]} '

# Query Result value
# Display Results: Query result 90 and query outcome 210
Peer Chaincode query-c mychannel-n mycc-v ' {v0-c ': [' query ', ' A ']} '
Peer Chaincode query-c mychannel-n mycc-v ' {v0-c ': [' query ', ' B ']} '


7. Close:

Enter Directory Fabric-samples/basic-network:

# CD fabric-samples/basic-network/

Close containers using Docker-compose:

# Docker-compose Down

Check it:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.