The revolutionary vision of a peer-to-peer version of electronic money published in 2008 by Satoshi Nakamoto, in “Bitcoin: A Peer-to-Peer Electronic Money System”, quickly took over the developer community. While bitcoin and the cryptocurrency concept were the ideas that initially captured the world’s imagination, Nakamoto’s article also brought a second concept: blockchain. Based on an accounting system, the novelty could offer a transport mechanism not just for bitcoin, but for any digital object.
However, what are the best practices for creating efficient blockchain applications? Simply inserting data into something like that and manipulating the information with codes inherent in smart contracts, or chain codes (chaincodes), is not enough. To be successful, developers need to master some architectural styles and the most appropriate actions. This article provides a set of best practices that can assist you in creating effective blockchain applications.
1 – Take advantage of cases already available
Before starting the development of a blockchain application, the team of developers needs to conduct a survey of cases that describe the best practices for the business problem they intend to solve.
Here, it is interesting to consider the three other rules for IBM’s blockchain:
There must be a business problem to be solved;
There must be an identifiable commercial network;
There must be a basis of trust in the commercial network.
IBM also provides a comprehensive page of successful cases of blockchain use that developers can count on before starting their processes.
Another important feature is the IBM Garage, a paid solution built from a methodology based on design thinking that can assist professionals in the development of minimum viable product (MVP).
Projects should not be initiated without the definition of one or more cases as guides. With case studies, it is possible to find the most popular and most successful solutions provided by the supply chain space in which to operate.
More information about cases in the coffee industry can be found in “Coffee supply chains are now going the blockchain way.”
In addition, IBM Developer code patterns for blockchain is another useful tool, offering open source code ready for use by developers.
2 – Clone an existing application
Blockchain technology is still relatively new, and many development teams may not feel comfortable working with it unless they have considerable experience in the field. That is why you find applications of the type appearing only in certain areas, such as supply chains – taking coffee supply chains as an example. Once successful in a given commercial branch, such as the one mentioned above, a series of clones will emerge from existing solutions applied in related fields – such as coffee news in different geographical areas.
Since many of these applications are open source, especially those based on different Hyperledger technologies, such as Hyperledger Fabric, a recommended first step for a newly created developer team is to clone an existing blockchain application and apply it to a domain. slightly new. In the case exemplified in this article, alternatives in the coffee supply chain offer a good starting point.
Speaking specifically of the blockchain application development team, how should it be formed? The team should include:
A chief architect with experience and deep knowledge in cryptography, performance and best practices for blockchain architectures;
A domain specialist aligned with the architect;
Some blockchain developers and operators.
That is, a total of six developers is ideal to start – a number that can grow with the project. Survey of costs is outside the scope of this article.
3 – Understand Fabric concepts
A good overview of basic blockchain concepts that you need to know and be incorporated into the structure of the Hyperledger Fabric can be found in the article: “Blockchain basics: Hyperledger Fabric.”
See the key components:
Assets: what you insert and what you are looking for in a blockchain using smart contracts;
Distributed ledger: record that records the status and property of an asset;
Smart contracts or chain codes (chaincodes): software that defines assets and related transactions;
Requisition service: packages transactions in blocks and guarantees the delivery of the transaction on the network. The main ones are Raft and Kafka.
As mentioned earlier, the best way for a development team to quickly familiarize themselves with these concepts is to reimplement an existing open source project, such as the Blockchain Bean or another successful Hyperledger Fabric based one.
4 – Choose the most suitable platform
There are many platforms and development tools aimed at creating blockchain applications. This article focuses on the following three:
Visual Studio Code;
IBM Blockchain Platform.
Hyperledger Fabric is an open source project managed by the Linux Foundation built to be used as a basis for the development of applications or blockchain solutions with modular architecture, allowing plug-and-play components. Its modular and versatile design encompasses a wide range of industrial cases, offering a unique approach to large-scale performance while preserving, at the same time, the privacy of its users. What’s more, Hyperledger Fabric includes excellent documentation.
Visual Studio Code
Visual Studio Code, combined with the Blockchain VSCode extension, helps developers to create, test and debug smart contracts, in addition to allowing the connection with Hyperledger Fabric environments and enabling the construction of applications that transact on your blockchain network.
After deciding the base case, the team uses the Hyperledger Fabric combined with the VSCode extension to create a blockchain application with smart contracts. The VSCode extension comes with a gallery of easy-to-follow tutorials focused on manipulating blockchain in such cases.
In other words, we use the VSCode extension to create, package, install, instantiate, submit and evaluate smart contracts.
More information about smart contracts can be found in the “Create and execute a blockchain smart contract” code standard – and they are the primary way to create blockchain applications.
The tutorial gallery for the VSCode extension is certainly the place to start learning how to create smart contracted blockchain applications on the Hyperledger Fabric and IBM Blockchain Platform.
IBM Blockchain Platform
The IBM Blockchain Platform is a cloud-based platform for creating and running enterprise blockchain applications on an infrastructure of your choice. Today, it is possible to deploy the IBM Blockchain Platform on public clouds, such as IBM Cloud, AWS or Azure – or perform the process on private clouds with secure infrastructures, such as LinuxONE.
Although many teams start their development journeys with Hyperledger Fabric or some other related solution, it is almost certain that they will end up deploying their applications in the public cloud or in multiple clouds with different configurations.
5 – The ledger and the blockchain
A shared, replicated and authorized ledger
Participant A records
Participant B Records
… with consensus, origin, immutability and definition.
Once a well-documented case is identified, the team then focuses on structuring the commercial network. The commercial network uses a shared ledger that is accessible to all participants (and this item was mentioned in section 3, just above.) Commercial ledgers have been present in companies for a long time as a way of managing business transactions. However, traditional models always bring the need to match the information in each participant’s book with that of everyone else in the network – which can be both laborious and error-prone.
Ending this need to compare information by allowing all members of a commercial network to use the same shared book is a historic innovation. This also provides consensus that stands out in any network. All participants must agree to an action before any transactions can be carried out in the ledger.
The ledger uses a shared blockchain with the following characteristics:
Consensuality, since Raft or Kafka help to structure greater fault tolerance for the blockchain;
Follow-up, as cryptographic hashes, such as SHA256, signal any changes in blockchain transactions;
Security, since digital signatures ensure that transactions are not created by imposters;
Provenance, given the possibility to trace the origin of an item on a blockchain;
Immutability, ensuring that data entered cannot be changed;
Definition, ensuring that transactions are considered immediately finalized after being included in a block and added to the blockchain.
For more information on ledger, read “Blockchain basics: Introduction to distributed ledgers.”
In-chain and off-chain
Even with this information, it is important to know that the development team is not limited to connecting a blockchain and running it. Members need to start by determining which data belongs to the blockchain and which does not. For example, it is not possible to insert gigabytes or terabytes of information into a blockchain if quick searches are required – and such searches are one of the essential features provided by an application.
In addition, some data may already exist in inefficient and personalized banks that do not need to be eliminated or replaced. Rather than stopping a blockchain, it is best to keep this information in the application itself via off-chain links as needed. The “off-chain” concept is the key to developing successful blockchain applications. This means that your solution is part of others that did not need to be eliminated unless absolutely necessary.
Finally, do not forget that personal data should never be inserted into a blockchain without first being anonymized, respecting data protection laws, such as the European Union’s General Data Protection Regulation (GDPR).
An advantage offered by blockchain is the ability to search the block chain for something and quickly find the information you want – something impossible to accomplish with paper records, which are still, surprisingly, used in many traditional ledgers. Many blockchain solutions allow companies to scan forms, supporting evidence and allowing digital signatures.
Another common use of off-chain storage is to support the caching of the most recent values of the state of the data in the chain or to take advantage of a technology suitable for that purpose, such as advanced research and analysis to guide the application’s interaction with the network. .
Often, sensitive data must be stored off-chain, since, by definition, information inserted into the blockchain cannot be changed or deleted. To learn more about the subject, take a look at the Private Data Collections in the Hyperledger Fabric guide.
In-chain or off-chain issues are the responsibility of the chief architect and the main factors that determine whether a blockchain application is created or broken.