Start from scratch, create and play your own blockchain in 5 minutes (photo guide)

Source: Internet
Author: User
Tags hyperledger fabric

Disclaimer: This document is only used for learning and communication purposes and should not be used for any other commercial purpose
Author: Chaoyang _tony
e-mail: [Email protected]
Create date:2016-7-18 10:31:15 Monday
Last change:2016-7-18 11:31:22 Monday
Reprint Please specify source: Http://blog.csdn.net/linzhaolover

Objective

Blockchain development this year is really fast! From the first unfamiliar concept, to now has started in various industries, a spark of great prairie fire. I wish I could have my own blockchain practice practiced hand O (∩_∩) o~! But a person, a computer, how to set up the blockchain environment ... Fire to not the blockchain, want to say love you not easy!

Don ' t worry! Small series has been addicted to blockchain and smart contracts can not extricate themselves! Take your hands off the ground now and play your own blockchain in 5 minutes!

The Supervessel platform developed by IBM China Research Institute provides blockchain enthusiasts, developers, and development test environment. The platform allows users to create multi-node blockchain based on Hyperledger fabric for free, ultra-fast, and fancy-play smart contracts on their own chains.

Preparatory work

Just need your local browser!

Register an account

Access the public address of the hyper-cloud (Supervessel) Blockchain service HTTP://CRL.PTOPENLAB.COM:8800/BC

Click on the Log In button in the top right corner and click Register in the Pop-up window to submit the email and password. It is recommended to go to the mailbox to view the activation email, and activate their own account (small tip: Lazy activation is OK, only some advanced services must be activated to use OH).

Quickly create your own blockchain

After registration is complete, go back to the homepage and click on the huge give me a BLOCKCHAIN (give me a blockchain!). button In the pop-up box, select the consensus Plugin (consensus plugin) and size (number of blockchain network nodes) you want.

Note: There are currently two common consensus plugins available from Hyperledger Fabric: Noops and pbft**.

After clicking Submit, a few seconds later you will be able to get your own blockchain and automatically enter the monitoring panel. Yes, it's so easy to get a blockchain that belongs to you!

After entering the monitor panel, we can see that the left side is the Intelligent Contract Management panel, including the management and deployment of the intelligent contract, the right side is the network panel, showing the application to the blockchain network situation, topology, the delay between nodes, etc. at a glance, click the telescope icon in the upper right corner, you can monitor the log information of each node At the bottom is the blockchain panel, which shows the overall situation of the current blockchain, with only one block in the initial state.

Deploy and use smart contracts

Next, a small compilation teaches you how to deploy and use smart contracts on your own blockchain.
2 Smart contracts are listed under smart Contracts (smart Contracts) tab of the Intelligent Contract Management panel as examples of maps and CHAINCODE_EXAMPLE02, respectively. Where the map contract can be used to store key value pairs (key-value), the CHAINCODE_EXAMPLE02 contract can simulate the transfer and query of two people.

Note: The code for these 2 example contracts can be found in the Hyperledger fabric source (https://github.com/hyperledger/fabric/tree/master/examples/ CHAINCODE/GO).

To deploy and use the CHAINCODE_EXAMPLE02 contract as an example:

Deployment contract

Click the Deploy button for the CHAINCODE_EXAMPLE02 contract and fill in the initial value of the contract, including the contract name, initial function, and initial parameters. The initial function of the contract is INIT, the initial parameters are to be filled out in format, such as ["a", "three", "B", "200"] means to register two persons A and b, respectively, to their 100 units and 200 units.

Click the Deploy button and the contract will be deployed in your blockchain, which takes approximately 20-40 seconds. When a new chunk appears in the blockchain panel, it usually indicates that the contract has been deployed.

Call contract

After the deployment is complete, view the deployed contract instances under the My Deployment (my Deployment) tab of the Smart Contract Management panel.

Click the Invoke button under action to invoke the smart contract, and fill in the method name and corresponding parameters of the call (the method name and parameter of the different contracts have different meanings, which are related to the contract content). For the contract, call the Invoke method name, fill in the parameters ["a", "B", "50"], and indicate a to B to 50 units.

After clicking Submit to complete the call, you can view the blockchain situation, and a new chunk will be generated.

Search contract

After the call is complete, you can then query the result of the contract execution. Still under the My Deployment tab, click the Query button under action to inquire about the smart contract and fill in the query's method name and corresponding parameters. If you select the Query method name, fill in the parameter ["a"] to indicate the current unit of query A.

When you click Submit, you can see that the current unit of a is 50. You can go to query B again!

OK, next you can continue to work on the contract, observe the blockchain, or deploy a new smart contract on the blockchain, such as map. For ease of use, the method name and parameter format of the deployment, invocation, and query contracts are all filled in by default, so you just have to choose a method name, tiger change the parameters! See how long you can play the chain ~

Upload and test your own private intelligence contract

In addition to the two public smart contracts currently available, you can upload and test your own private contracts! Private contracts can only be seen by themselves.
Under the Smart Contracts tab, click Import Private Smart Contract.

Fill in the contract name and description, and upload the contract code file, click Import, complete the upload.

After that I uploaded the contract in the smart contracts list and can deploy, invoke, and query as before.

Interested developers may wish to learn about the contract examples in Hyperledger fabric source (https://github.com/hyperledger/fabric/tree/master/examples/chaincode/ Go), write and test your first smart contract on the platform!

Today's tutorial is here, you are welcome to participate in public beta, and in the background of the public or to our email [email protected] Send feedback!

Start from scratch, create and play your own blockchain in 5 minutes (photo guide)

Related Article

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.