Hyperledger is an Opensource platform to create blockchain applications in a business network of
Business character.
To do this, the philosophy pursues is that network participants must be known, the networks must be
permitted, you must have a transactions rate for second very high and must save the deprived and
Confidentiality of transactions and data.
Among the use cases that Hyperledger are applying we can find Supply Chain, Provence, Property Rights, Fintech, Healthcare, among others.
Hyperledger consists of several sub-projects or frameworks (Burrow, Fabric, Iroha, Sawtooth) and several tools (Caliper, Cello, Composer, Explorer, Quilt).
Hyperledger is governed by Linux Foundation and has a great support by IBM.
The best known of Hyperledger is Fabricand Composer.
Fabric is the most active of the current 10 projects. This tutorial is focused on Hyperledger Fabric.
Hyperledger Iroha
Initially, he had contributions from Soramitsu, Hitachi, NTT Data and Colu. It is focused on the simplicity of implementation using C ++, emphasizing the development of mobile apps and using the YAC consensus algorithm.
By the way, if you want to get free cryptocurrencies when learning, you can take a look at Coinbase that is also an excellent exchange.
Hyperledger Indy
This framework is focused on the digital identity on the Internet. Use DID (decentralized identifiers) and verifiable credentials to add a layer of identity on the Internet.
Hyperledger Sawtooth
It has been one of the first projects to join Linux Foundation and is surrounded by Intel. It allows permitted or non -permitted use. Use the proof of elapsed time consensus algorithm
Hyperledger Fabric
It has been one of the first projects to mature, under the hand of IBM. Use Peers, an Ordering Service and a membership server. It has the ability to use Smart Contracts (called Chainode) and allows the use of several channels.
FabricIt is a private DLT permitted with channel support. You don't need one
cryptocurrency
to function.
ComposerIt is a set of tools for modeling and building business networks in blockchain.
Built with JavaScript, it uses several tools well known as Node.js, NPM and Yeoman.
Fabric can use plug and play -type consensus models, to adapt to each useful case the most
efficient.
For example, if used in a single company, a type consensus algorithm can be used Crash
Byzantine Fault TolerantWhile if used among several companies could use an algorithm
of
Type consensus Byzantine failures tolerant
It is permitted, that is, it is administered who can read or write in the blockchain.
Save the status of digital assets in a "key-value" database.
Has Smart Contracts called "Chainode", which can be implemented in go or
Java or JavaScript.
You can also use an identities management of plug and play, such as LDAP or Openid, to adjust to
the
needs of each company or use case.
Fabric design works with several coms coms are the ASSETs, Chainode, Ledger, Privacy, the membership services and consensus.
Assets allow to model the exchange of anything that has value through the business network,
From food, cars or currencies.
Even intangible things as contracts or rights of intellectual property.
Basically they are stored as a collection of "key-value" pairs with registered state changes such as
Transactions in the Ledger.
Chainode allows these ASSETs to be modified, through business logic the rules to read or Alter these "key-value" pairs or other information from the "State" database.
In the Ledger all the changes of states are kept, sequentially and resistant to the manipulation of
These data.
These state changes occur from the invocations of the chainode in the form of transactions
that
Several business network participants broadcast.
Thus the Ledger is composed of a blockchain to store the sequence of changes and a base of
States data.
Through the use of channels, the privacy of network transactions is maintained.
Since all business network participants have known identities within a
organization, pki with certificates x509 is used to generate cryptographic certificates to
Organizations, participants or users of applications.
There are also the membership service providers that define within the organization the role of
Each peer.
The consensus algorithm is the fundamental piece when ordering transactions in a block, from The proposal and the "endorsement" to the ordination, validation and writing.
A business network consists of several nodes that are communicated by the network. There are 3 types of nodes: customers
that send transactions to the peers,
Peers who record the transitations, maintain a copy of the LED and the State and the Ordering
Service that order, validate transactions, put them into blocks and send them to the Peers.
The certified authority service is used to generate certificates and keys to manage and
Configure the identities of the business network.
Ordering Service orders time transactions and prepares them to include them in a block.
Peers that belong to organizations, store the LEDger and the Smart Contracts.
Transactions are recorded in the blockchain, while the state of the ASSETs is stored in a
database.
Both the state of the ASSETs and the records are shared between the various peers of the system using
The consensus algorithm.
To define a business network, at least one Ordering Service is needed. This is configured and managed by an administrator of a certain organization, giving only permits to that organization. Subsequently, at least one peer is added that stores a copy of the LEDger. This peer communicates with the Ordering Service using a channel.
Below is how applications interact with the Peers to access the LEDger. The
consultation transactions are returned immediately,
while transactions containing updates require interactions between applications,
Peers and Ordering Services.
An ASSET is a digital asset modeling within the Hyperledger system. It can be anything from a car, a food, etc ... have an identifier and several properties, and may be related to Other ASSET or with participants.
A participant is an actor of the network who can be the owner of an ASSET and can send transactions. To the Like an ASSET, they consist of an identifier and several properties.
They are defined by a digital certificate with their private key, they are assigned to the participants of the application. These identities are kept in the "cards".
They define the business logic of the application. In other words, participants are related to ASSETs.
Define consultations about the state of the Blockchain Assets.
They are defined in modeling file and allow the world off-chain to realize the on-chain changes. The applications can subscribe to several events and thus show specific alerts of what happens in ASSETS
Allow to define the permits of the participants when accessing the various ASSETs
It is a set of tools to develop and expedite the creation of blockchain applications. HE
communicates with manufacture in a very easy way and allows to design concept tests and deploy in a matter of
a few weeks.
Composer packages all files on a BNA file (Business Network Archive).
A bna file contains:
All this is packaged in a BNA and allows you to display a blockchain application easily in several environments, whether local or in the cloud.
To execute Hyperledger Composer, it can be done on the local computer or in the cloud (Bluemix of IBM). It is used what is called a "playground", which is a test environment where we can edit all the previous files and deploy them in Fabric de transparent way. It allows to model and test a blockchain application easily and quickly.
The playground is already preloaded with several examples, so it is highly advisable to use it to Get an idea of how to model a blockchain application within the Hyperledger ecosystem.
When choosing an environment to install Hyperledger, it is advisable to use a Linux version, in General is recommended an ubuntu 16.04 or a macOS.
A whole series of programs that are the following are needed:
There is a github script that manages the requirements. We can install it with curl. If we don't have
installed curl we will do it with:sudo apt install curl
The script is then downloaded and executed:curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
prereqs-ubuntu.sh
To install the composer you have to use NPM to install several tools:
npm install -g composer-cli
npm install -g composer-rest-server
npm install -g generator-hyperledger-composer
npm install -g yo
npm install -g composer-playground
There is another script that contains the Fabric Installation script. We create a directory, we download the script with curl and unpack it:
mkdir ~/fabric-dev-servers && cd ~/fabric-dev-servers
curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
tar -xvf fabric-dev-servers.tar.gz
cd ~/fabric-dev-servers
./downloadFabric.sh
To start manufacture we do:
andcd ~/fabric-dev-servers
./startFabric.sh
To stop Fabric we do:
./stopFabric.sh
And to start the playground:
composer-playground
Once this we can access the playground from the browser in the URL:http: // localhost: 8080
It can be installed KitematicTo handle Docker containers visually and InsomniaTo handle the requests to the Rest APIs if desired.
The first step is to create a definition of the business network. There the data model is defined, the
logic of transactions and access rules.
Yeoman can be used to generate a skeleton:
yo hyperledger-composer:businessnetwork
Once we have developed the models and business logic we can pack it with:
composer archive create -t dir -n .
This will create a type file mired@0.0.1.bna
Here are the credentials of the business network administrator:
createPeerAdminCard.sh
With that we are created a "card" called "peeradmin@hlfv1"
Then you have to install the BNA in Fabric:
composer network install --card PeerAdmin@hlfv1 --archiveFile mired@0.0.1.bna
Then start the network:
composer network start --networkName mired --networkAdmin admin --networkAdminEnrollSecret adminpw
--card PeerAdmin@hlfv1 --file miredadmin.card --networkVersion 0.0.1
Import card:
composer card import --file miredadmin.card
We can make a ping to the business network:
composer network ping --card admin@mired
And even publish an API Rest to communicate with the blockchain:
composer-rest-server
There is an option to generate an angular application skeleton using Yeoman:
yo hyperledger-composer
This application can be started with:
npm start
To update a BNA, the following steps are required:
Change the "version" of the package.json from 0.0.1 to 0.0.2
Create the package this time with the name: mired@0.0.2.bna
Install the new network in Fabric:
composer network install --card PeerAdmin@hlfv1 --archiveFile mired@0.0.2.bna
Upgrade the network to the new version:
composer network upgrade -c PeerAdmin@hlfv1 -n mired -V 0.0.2
Make a ping to the network:
composer network ping --card admin@mired
Regenerate the API Rest:
composer-rest-server
Models use object -oriented language, similar to a Java language. A name space is used to
Group resources:namespace org.tutorial.basic
Then these can be imported within other files.
import org.tutorial.basic
The primitive types are: String(UTF8), Double(64bit decimal number), Integer(whole number with sign 32 bit), Long(whole number with 64bit sign), Datetime(Date and time with Timezone) and Boolean(A value true or false).
Default values with the keyword can be assigned:
or optional values
With the word:default="texto"
optional
Arrays can be defined with brackets [] and enums:
enum Estado {
o PENDIENTE
o FINALIZADO
}
Then you can define Assets with the word
that can inherit from other ASSETs with the
wordasset
The properties of an ASSET are defined with an "or" the type of data and the name of the property. And if
We want to include a relationship is defined with "->"extends
Next, participants can be defined with the word
that can inherit from
Other participants with the word:participant
The properties of a participant are also defined with an "or" type of data and the name of the
property. And if we want to include a relationship it is defined with "->"extends
The same applies to transactions and events, they can inherit and include properties and relationships.
There is an abstract class type that does not represent Assets, participants or transactions. They cannot be
Referenced. They serve to group properties:
abstract concepto Direccion {
o String calle
o String ciudad
o String pais
}
To define the execution logic, JavaScript files are used. Use comments and metadata to
Define these functions.
They are described as
Because they are oriented to events like Node.async nombreTransaccion()
They are atomic and we can launch an exception with
which causes a rollback and all changes are lost.throw new Error("error")
Within the code you can use several bookstores: Common, Runtime, Admin, and Client.
These allow to manage assets, issue events or manage the network.
Business network consultations are defined in files .qry. The consultations are preceded by the word
Query and contain a "description" and a "statement" that is the database consultation
proper.query seleccionaMiAsset {
description: "Selecciona todos los assets de tipo MiAsset"
statement: SELECT org.tutorial.MiAsset
}
It is possible and recommended to define all this complete code in the playground and test it directly.
You can even export all the full code to a .bna file for its deployment in Fabric operating in our local network.
Этот веб-сайт использует файлы cookie для получения статистических данных о навигации своих пользователей. Если вы продолжаете просмотр, мы считаем, что вы принимаете его использование. политики cookie