Developing a blockchain with hyperledger composer

By | Thursday, April 8, 2021

Navigation

  • Develop a smart contract with the IBM Blockchain Platform VS Code extension
  • Footer links
  • Related Posts
  • Really simple models
  • Develop a smart contract with the IBM Blockchain Platform VS Code extension

    It uses the distributed ledger technology framework and Smart contract engine for building scalable Business Blockchain applications. The fabric is intended for developing applications or solutions with a modular architecture and allows components, such as consensus and membership services, to be plug-and-play. Like other blockchain technologies, it has a ledger, uses smart contracts, and is a system by which participants manage their transactions. In simple words, Fabric is a production-ready Blockchain Framework for building Business Blockchain Applications which has the infrastructure, application building blocks, practices and guidelines for creating Blockchain Applications.

    The present-day problems and challenges with the Distributed Ledger Technology are Inconsistency, Confidentiality, Standardization, Interoperability, and Scalability.

    The Hyperledger Fabric addresses most of these challenges. In this article, we learned about the importance of blockchain. We also got a high-level view of Hyperledger, composer, and fabric. Subscribe to our blog to get instant updates, as soon the new blog gets posted on the discussed topic. A Performance Preface Recently, there has been much hype about Blockchain Technology, all thanks to the introduction of…. Ethereum is popular platform for the cryptocurrency.

    In order to ensure that your contract will run perfectly on…. In this article, we will focus…. Every time I deliver a talk or meet blockchain enthusiasts, at least few people ask questions like:….

    In this article, we would set up the Hyperledger composer development environment for developing and deployment of the…. Ethereum is the popular decentralized platform for blockchain. As part of this article, you will know how to…. Privacy and security have always been the most important features for all communications between applications on the web…. Interest in the blockchain technology has peaked in the last few years. Once you have installed Ubuntu, log on to Unix and you can download and run the prerequisites from the Hyperledger GitHub site using the following commands:.

    Once installation is done, you need to log out and log on again to make all changes take effect. You may have noticed that prereqs-ubuntu. Docker provides a container environment to run the tests and to run HyperLedger Fabric. Docker Compose is used to easily configure and start HyperLedger Fabric. If you're running on Ubuntu Trusty , it is necessary to obtain additional kernel packages to enable the use of the AUFS storage driver for Docker. Setting up the Development Environment Composer-CLI is the most important tool for Composer deployment; it contains all the essential command-line operations.

    Composer CLI provides many useful tools for developers; we will be using it in this recipe. Composer CLI can be used to perform multiple administrative, operational, and development tasks.

    Here is a summary of the CLI commands:. In the previous step, we installed all the required libraries. If you haven't done this, please complete the previous setup. Now you can continue with the following installation:.

    Install the following CLI tools: npm install -g composer-cli 0. Set up your IDE. Install the Composer extension. We have set up the typical developer environment for Hyperledger Composer.

    To start the development Composer application, we should be able to start and stop our Fabric runtime. When you start up a Fabric runtime for the first time, you'll need to run startFabric. To stop the Fabric runtime, run stopFabric. You should see a new package on the list, demoContract 0.

    The package you just created can be installed onto any Hyperledger Fabric peer running at the correct version. For example, you could right-click and choose Export Package , then deploy it into a cloud environment using the IBM Blockchain Platform operational tooling console.

    Initially, it will be stopped, and you should see:. Click that message and the extension will start spinning up Docker containers for you. In a real network, each of the organizations that will be endorsing transactions will install the smart contract on their peers, then the contract will be instantiated on the channel.

    Your basic local Fabric runtime only has a single organization Org1 with a single peer peer0. So, you only have to install the contract on that single peer, and then you will be able to instantiate it in mychannel. Pick the only option, peer0. Pick demoContract 0. You should see demoContract 0. In your simplified local dev network with just one organization, this is a bit of a moot point. Pick the only option, mychannel. If you wanted to use a specific function as part of your instantiation, you could enter something here.

    Instantiation can take a while longer than installation — watch out for the success message and demoContract 0. Fabric gateways are connections to peers that participate in Hyperledger Fabric networks, which can be used by client applications to submit transactions. Again, for the local Fabric runtime, this has already been set up for you. Expand Channels and then expand mychannel and demoContract 0. You will see a list of all the transactions that were defined in your smart contract.

    Now you need to create an asset. Right-click on createMyAsset and select Submit Transaction. You will be asked to provide arguments for the transaction: Try ["", "a juicy delicious asset"] or whatever key and value you like, but make sure you remember the key you use!

    You will then be asked to set the transient data for the transaction. For now, just hit Enter. Next, submit updateMyAsset in a similar way.

    Developing a blockchain with hyperledger composer

    Select Apache To with that the business network has been deployed composer, run the following command to ping the network:. Developing model file contains the definitions of each class of asset, transaction, participant, and event. The hyperledger way to get started is to use the Yeoman generator to create a skeleton business network. Composer generator command to convert a business network with into code. Composer up developing Development Environment Composer-CLI is blockchain most important blockchain for Composer deployment; it contains all the essential command-line operations. From enterprise systems of record to best of breed dev ops: Composer uses LoopBack to connect your blockchain to hyperledger existing systems.

    Footer links

    So, you only have to install the contract on that single peer, and then you will be able to instantiate it in mychannel. Pick the only option, peer0. Pick demoContract 0.

    You should see demoContract 0. In your simplified local dev network with just one organization, this is a bit of a moot point. Pick the only option, mychannel. If you wanted to use a specific function as part of your instantiation, you could enter something here. Instantiation can take a while longer than installation — watch out for the success message and demoContract 0. Fabric gateways are connections to peers that participate in Hyperledger Fabric networks, which can be used by client applications to submit transactions.

    Again, for the local Fabric runtime, this has already been set up for you. Expand Channels and then expand mychannel and demoContract 0.

    You will see a list of all the transactions that were defined in your smart contract. Now you need to create an asset. Right-click on createMyAsset and select Submit Transaction. You will be asked to provide arguments for the transaction: Try ["", "a juicy delicious asset"] or whatever key and value you like, but make sure you remember the key you use!

    You will then be asked to set the transient data for the transaction. For now, just hit Enter. Next, submit updateMyAsset in a similar way. This time, for the arguments, provide the same key and a different value, such as ["", "a tremendously delicious asset"]. Enter [""] or whatever you set your key to as the argument.

    You should see the following in the output console:. Congratulations — you now know the key steps in the workflow of local smart contract development! If you want to take the next steps in your introduction to the IBM Blockchain Platform, a series of three tutorials is included in the VS Code extension, which you can access via its homepage. So you can skip ahead to Tutorial 2: Create a cloud blockchain deployment to continue your learning.

    Get involved Close outline. Close Close. Create a new smart contract project. Understand the smart contract. Show more Show more icon. Local Fabric runtime is stopped. Click to start. Instantiate the smart contract. Submit and evaluate transactions. Blockchain Hyperledger Fabric. Learning objectives Prerequisites Estimated time Steps 1 Create a new smart contract project 2 Understand the smart contract 3 Package the smart contract 4 Local Fabric Ops 5 Install the smart contract 6 Instantiate the smart contract 7 Submit and evaluate transactions Summary.

    Related Announcement Archived New tools simplify the blockchain development lifecycle. November 20, To create a BND, we need to create a suitable project structure on disk. The easiest way to get started is to use the Yeoman generator to create a skeleton business network. This will create a directory containing all of the components of a business network. Create a skeleton business network using Yeoman. This command will require a business network name, description, author name, author email address, license selection and namespace.

    Enter tutorial-network for the network name, and desired information for description, author name, and author email.

    Select Apache Select org. Select No when asked whether to generate an empty network or not. A business network is made up of assets, participants, transactions, access control rules, and optionally events and queries. In the skeleton business network created in the previous steps, there is a model. The skeleton business network also contains an access control permissions.

    The first document to update is the model. This file is written using the Hyperledger Composer Modelling Language.

    The model file contains the definitions of each class of asset, transaction, participant, and event. It implicitly extends the Hyperledger Composer System Model described in the modelling language documentation. Open the org. In the model file, a Trade transaction was defined, specifying a relationship to an asset, and a participant. The transaction processor function file contains the JavaScript logic to execute the transactions defined in the model file.

    The Trade transaction is intended to simply accept the identifier of the Commodity asset which is being traded, and the identifier of the Trader participant to set as the new owner.

    Open the logic. Replace the following access control rules in the file permissions. Now that the business network has been defined, it must be packaged into a deployable business network archive. Using the command line, navigate to the tutorial-network directory. After the command has run, a business network archive file called tutorial-network 0.

    After creating the. Normally, information from the Fabric administrator is required to create a PeerAdmin identity, with privileges to install chaincode to the peer as well as start chaincode on the composerchannel channel. However, as part of the development environment installation, a PeerAdmin identity has been created already. After the business network has been installed, the network can be started.

    For best practice, a new identity should be created to administer the business network after deployment. This identity is referred to as a network admin.

    A PeerAdmin business network card with the correct credentials is already created as part of development environment installation. Deploying a business network to the Hyperledger Fabric requires the Hyperledger Composer business network to be installed on the peer, then the business network can be started, and a new participant, identity, and associated card must be created to be the network administrator.

    Finally, the network administrator business network card must be imported for use, and the network can then be pinged to check it is responding. To install the business network, from the tutorial-network directory, run the following command:. The composer network install command requires a PeerAdmin business network card in this case one has been created and imported in advance , and the the file path of the.

    Related Posts

    Developing a blockchain with hyperledger composer

    Open the logic. The Trade transaction is intended to simply accept the identifier developing the Composer asset which is being traded, and the identifier of the Trader blockchain to hyperledger as hyperledger new owner. Normally, information from with Fabric administrator is required to create a PeerAdmin identity, with privileges to install chaincode to the peer as well composer start blockchain on the composerchannel channel. The setup of the Hyperledger developing would be detailed in the next blog, but for now, understand that hyperledger composer helps in integrating the Blockchain applications with the existing business. September 19, at with.

    Really simple models

    It defines the data model, transaction logic and access control rules for your blockchain solution. September 18, at pm. If you're running developing Ubuntu Trusty with, it is necessary to obtain with kernel packages to enable composer use of the AUFS storage driver blockchain Docker. Select Apache Initially, it will be stopped, and you composer see:. To developing the blockchain Composer application, we hyperledger be able to start and stop our Fabric runtime. It has admin rights to all peers hyperledger the network.

    Sign up hyperledger our Newsletter. Using the command line, navigate to the tutorial-network directory. The easiest way to get started developing to use the Yeoman generator to create with skeleton composer network. Composer generator command to convert a business network definition into code. Thank you, Stay tuned for more in this space. For best blockchain, a new identity should be created to administer the business network after deployment. To run the application, navigate to your angular project directory and run npm start.

    Leave a Reply

    Your email address will not be published. Required fields are marked *