How to build a blockchain app for tracking of manufactured parts

Contents

Contrary to popular belief, blockchain is not only about cryptocurrencies. Thanks to its features such as security, non-repudiation, immutability, and performance, blockchain technology can bring considerable benefits to many industries: logistics, financial services, energy, and manufacturing to name a few. In this article, you will be presented a proof of concept of an app based on Hyperledger Fabric, an open-source blockchain for business.

The number of blockchain apps (also called distributed apps or DApps) is constantly growing. Among them, there are many dedicated for such sectors as health, energy, and security. Despite the hype they may arouse among the general public, cryptocurrencies (including Bitcoin and Ethereum as well as hundreds of less well-known ones) and NFT tokens, which have been so popular recently, do not constitute all possible uses of blockchain technology. In fact, more and more companies are working on using blockchain in practical business cases.

A good example of this trend is Hyperledger Foundation (formerly known as Hyperledger or the Hyperledger Project). It is an umbrella project aiming at developing blockchain-based distributed ledgers and related tools that can be used for business purposes. It is hosted by Linux Foundation and supported by many companies including giants like IBM, Hitachi, Fujitsu, and JP Morgan Chase.

Hyperledger Foundation works on a number of blockchain-based projects, including Hyperledger Fabric, which we used in our proof of concept (PoC) of the application for tracking aircraft engines parts. The overview of other projects hosted by Hyperledger Foundation can be found on the interactive Hyperledger Landscape.

All this shows that blockchain app development is no longer a niche limited to gambling, NFTs, and cryptocurrencies but is becoming increasingly popular among enterprises. In fact, Gartner in its Tech Radar for 2022 puts smart contracts and distributed ledgers, i.e., the building blocks of blockchain, as two technologies that will have respectively high and very high business impact in the next three to six years.

What is Hyperledger Fabric?

Hyperledger Fabric is an open-source, enterprise-grade, distributed ledger technology (DLT) platform allowing companies to build private blockchain networks, central and private channels, as well as private (encrypted) data storage. Let us take a closer look at its features.

 

A permissioned blockchain

Hyperledger Fabric is a permissioned blockchain, which means that only identified participants can join it. Usually, there is some sort of an agreement or contract between participants that regulates participation and its governance ensuring trust. The participants of the network are enrolled through a trusted Membership Service Provider (MSP)—an abstract component of the Hyperledger Fabric that provides credentials allowing clients and peers to participate in the network. This component is pluggable, which means that you can adjust it to a particular business scenario without modifying the core of transaction processing components of the system itself.

More importantly, in a permissioned blockchain like Hyperledger Fabric, the risk of introducing malicious code through smart contracts is diminished. Since all participants on the network are vetted and known to each other, it is easy to identify who is behind a given transaction recorded on the blockchain.

For public blockchains, anonymity and being permissionless are the main advantages that led to a rapid development of cryptocurrencies. In business-related scenarios, they are obstacles, as business needs trust and security—to use the blockchain technology for business purposes, you need a private, permissioned blockchain like Hyperledger Fabric.

 

Shared ledger

At the heart of blockchain technology lies a distributed ledger that records all the transactions taking place in the blockchain network. It is distributed, which means that, unlike traditional central databases, a copy of it is stored on every node of the network. So, every blockchain participant has its own copy of the database.

What is important from the business point of view is that the shared ledger is immutable. You can record a new transaction to the blockchain in append-only mode once its correctness is verified. After that, you cannot change it. In this way, you can easily verify the provenance of information, and all participants can be sure that it has not been changed or tampered with in any way.

In Hyperledger Fabric, the ledger consists of two components: the world state and the transaction log. The world state contains the state of the ledger at a given point in time, while the transaction log records all the transactions and can be seen as the update history for the world state.

For those blockchain network participants that do not want to share their data with other participants, Hyperledger Fabric offers a private data functionality. To ensure data privacy and confidentiality, you can use channels, i.e., establish a sub-network where every member can see a particular set of transactions. Alternatively, you can create a collection. This works in the same way as channels, but without the need to create and maintain a separate channel.

 

Smart contracts

In Hyperledger Fabric, the business logic of a blockchain app is based on smart contracts (called “chaincodes”), which are programs stored on a blockchain that are run when determined conditions are fulfilled.

Typically, existing blockchain systems use order-execute architecture, where the consensus protocol validates and orders the transaction validation that is next propagated to all nodes of the blockchain. Then, these nodes execute this transaction sequentially. The sequential execution of a transaction is a serious drawback, though, that hinders performance and the scale of the system. Additionally, it makes it more difficult to ensure the entire system is protected from potentially malicious contracts.

Importantly, a smart contract based on order-execute architecture needs to be deterministic, as otherwise it may be impossible to reach a consensus. To cover nondeterministic scenarios, many blockchain platforms require that smart contracts are written in a domain-specific language (DST) that allows programmers to eliminate nondeterministic operations. So, in order to write a smart contract, programmers need to learn a DST language, which requires additional time and effort.

To address the drawbacks of typical smart contracts, Hyperledger Fabric proposed a smart contract based on execute-order-validate architecture. Here a transaction is not executed by all nodes but only by those that are necessary to ensure the correct execution of a given smart contract. These nodes are specified in an application endorsement policy. In this way, multiple smart contracts can be executed at the same time. Thanks to this feature, the overall performance and scale of the system is increased. It’s also very important that since the transaction is first executed and endorsed, nondeterministic scenarios are no longer possible and you can use general-purpose languages, like Java, Go, and Node.js, to write smart contracts.

 

Modular and configurable architecture

Hyperledger Fabric is composed of many modules that can be customized to fit a specific business scenario.

For example, a consensus protocol allowing all nodes in a blockchain to verify the correctness of a transaction (like Proof of Work in Bitcoin) is pluggable. So, depending on your needs, you can use the crash fault-tolerant (CFT) or byzantine fault-tolerant (BFT) consensus protocols.

Smart contracts, as said before, can be written using standard programming languages, which allows for greater flexibility. You can also configure the ledger to work with different Database Management Systems.

The platform also allows you to choose pluggable identity management protocols such as LDAP or OpenID Connect, key management protocols or cryptographic libraries.

 

No need for native cryptocurrency

In Hyperledger Fabric, there is no need to use a native cryptocurrency to use consensus protocols or fuel smart contract execution. Cryptocurrency mining is a costly operation requiring considerable computing resources. Additionally, it poses substantial security risks that should be minimized in business scenarios. All this makes Hyperledger Fabric a cost-effective solution, as its operational costs are comparable to the costs related to operating any distributed system.

 

The Hyperledger Fabric architecture

The most top-level components of the Hyperledger network are the organizations. They can represent actual enterprises or any other parties represented in the blockchain. Organizations join the network bringing with them their peers, orderers and certificate authorities (CAs), although they do not have to include all of them. Trust between them is established within the network with the help of MSPs.

Fig. 1 Hyperledger peers and organizations (source: Hyperledger Foundation)

  • Peers are nodes that store the ledger; initiate, endorse and validate the transactions; or interact with client applications.
  • Orderers are nodes whose responsibility is to order the blocks in the blockchain to make sure that no invalid blocks are stored to the ledger and that the order of the transactions is valid. Because of them, Hyperledger blockchain does not have forks.
  • CAs or Certificate Authorities are nodes that issue and validate X.509 certificates representing all entities within the network (from individual users to organizations).

From the development point of view, Hyperledger hides much of this architecture with its Gateway Service which automates the whole transaction submission and execution process. There are APIs for this service available in Node.JS (TypeScript), Go, and Java.

Regarding the technology stack, the Hyperledger software runs on Linux and can be easily run as docker images. Nodes communicate over http. Authentication and authorization heavily depend on X.509 certificates issued by CAs. They can be validated within a smart contract to ensure that only authorized parties are able to initiate transactions or read the ledger.

Hyperledger has really good documentation with a lot of examples that will facilitate your introduction to the platform. As of the end of November 2022, the current Hyperledger version is 2.4.7.

Why use Hyperledger Fabric

Thanks to its features, Hyperledger Fabric offers considerable benefits for business:

  • Trust—it is a permissioned blockchain where all network participants are vetted and known to each other.
  • Security—since it is easy to identify who is behind a given transaction, the risk of injecting malicious code through a smart contract is considerably lower.
  • Confidentiality—smart contracts (“chaincode”) ensure that all transactions recorded to the blockchain are confidential.
  • Data privacy—a private data feature allows you to share your data only with a selected set of network participants.
  • Performance—thanks to the parallel execution of smart contracts, the overall performance of the system is higher.
  • Cost effectiveness—there is no need for costly cryptocurrency mining.

For these reasons, we chose Hyperledger Fabric for our blockchain app development.

An app for tracking manufactured parts based on Hyperledger Fabric

In our PoC, we assumed that our client is a manufacturer of aircraft engines. In order to build a final product, it uses a large network of parts suppliers. Each part used in an engine is registered and tracked using blockchain technology that stores its metadata.

In the event of an engine failure, thanks to blockchain you can track down every part to know who supplied it, which quality controls it passed, etc. This information is accessible for government or private officials investigating the root cause of the failure.

In the process of registering the parts, there are three parties involved: the part supplier or suppliers, an engine manufacturer, and the auditing body. Suppliers and manufacturers save the information about the process to the shared Hyperledger channel.

The available functions are limited, based on the X.509 certificates provided. All parties, including the auditing body, have read access to the channel data, which allows them to track the supply and quality control history.

Each party has several user roles, which play particular roles in the process:

  1. Fan manufacturer
    • Warehouse worker
  2. Compressor manufacturer
    • Warehouse worker
  3. Engine manufacturer
    • Warehouse worker
    • Controller
    • Assembler
  4. Auditing body
    • Auditor

 

The architecture of our blockchain application

Our solution consists of two main components.

One is the blockchain/Hyperledger part, the other is a custom-developed client web application. The former contains all the pieces required by the Hyperledger platform: peers, orderers, and CAs, connected together by a common Fabric channel and using a custom smart contract deployed there. The latter is a single instance of the user interface, common for all the participants (note that in an actual case, this may or may not be true—each party may have their own interface by which they interact with the Hyperledger network).

There are two organizations in the PoC: a parts supplier and an engine manufacturer.

An important fact to note is that the whole blockchain logic is implemented within the smart contract in the Hyperledger channel using Typescript as the programming language. This includes:

  • reading from the ledger (data about parts, engines, their history),
  • writing to the channel (via transactions such as “perform quality control” or “assemble engine”),
  • validation (e.g., it should be impossible to use a part in the engine assembly process that has not previously undergone quality control),
  • authorization (only permitted users should be allowed to interact with blockchain, e.g., only a QA engineer may perform a quality control task).

 

The web application is a fairly thin client whose goal is to present the user with an interface to easily interact with the data inside the blockchain. There is no storage (database or otherwise) within the client application itself; all the data is read from and written to the ledger only. The operations are forwarded to and executed by the blockchain (“chaincode”).

A real-world example might include a database and other components. In fact, the blockchain component would probably be just one of the modules of a larger application that reflects the business needs and processes, for instance warehouse state management, workflows, approvals, reporting, etc.

The application consists of three tiers: a presentation layer (UI) written using React 18.2; a backend business logic layer implemented using .NET 6.0; and a gateway layer developed in NodeJS, which plays the role of the data access layer in a typical three-tier architecture.

Instead of accessing a database, the application uses Fabric Gateway API v1.1 to communicate with blockchain network nodes. The organizations share the top two layers but have their own gateways because they interact with different parts of the blockchain network and use different identities to do so. The layers communicate with each other using REST.

In the PoC, the UI and business logic layers are served from one docker image, the gateways and the Hyperledger nodes all from separate ones. The entire solution is heavily scripted to make the whole environment start up (and shut down) using a single command.

The architecture of our application is shown on the Figure 2:

Fig. 2 The architecture of the blockchain app for tracking manufactured parts

 

A blockchain app for tracking of manufactured parts—a sample workflow

A sample workflow in the app could look as follows:

  1. Supplier supplies a part and records this fact in the ledger.
  2. The engine manufacturer performs input quality control of the part and records this fact (and the results) in the ledger—see Figure 3:

Fig. 3 Quality control recorded in the ledger

  1. The engine manufacturer assembles the engine (in this example, the engine consists of only two parts). This fact is recorded in the ledger in both the engine’s and the parts’ histories.
  2. The engine manufacturer performs output quality control of the engine and records this fact (and the results) in the ledger.
  3. The engine manufacturer sells the engine to a customer.
  4. If needed, an auditing user is able to access the histories of all the parts and engines (see Figure 4). To better reflect a real-world scenario, the auditing body does not have its own instance of the sample app—instead it uses one of the others.

Fig. 4 The histories of all parts of the engines recorded to the ledger. 

Blockchain application development—wrap-up

Thanks to ensured trust, enhanced security, high performance, and cost-effectiveness, Hyperledger Fabric is a technology that allows companies to start their blockchain development. Our blockchain app for tracking manufactured parts shows how you can harness blockchain technology in the aircraft industry where data immutability, traceability, and non-repudiation are crucial for ensuring compliance and security.

In fact, Hyperledger Fabric has been already applied in other business scenarios: to track food supplies, process healthcare transactions, build a marketplace for used aircraft parts, build a loyalty platform, and to streamline the procurement process.

Hyperledger Fabric is in its adolescence now, but I believe it is something that will be developed in the future because the distributed ledger technology is based on decentralization and collaboration and the way it works closely resembles how the real business world works.

Sign up for the newsletter

You may also find interesting:

Book a free 15-minute discovery call

Looking for support with your IT project?
Let’s talk to see how we can help.

The controller of the personal data is FABRITY sp. z o. o. with its registered office in Warsaw; the data is processed for the purpose of responding to a submitted inquiry; the legal basis for processing is the controller's legitimate interest in responding to a submitted inquiry and not leaving messages unanswered. Individuals whose data is processed have the following rights: access to data, rectification, erasure or restriction, right to object and the right to lodge a complaint with PUODO. Personal data in this form will be processed according to our privacy policy.

You can also send us an email.

In this case the controller of the personal data will be FABRITY sp. z o. o. and the data will be processed for the purpose of responding to a submitted inquiry; the legal basis for processing is the controller’s legitimate interest in responding to a submitted inquiry and not leaving messages unanswered. Personal data will be processed according to our privacy policy.

dormakaba 400
frontex 400
pepsico 400
bayer-logo-2
kisspng-carrefour-online-marketing-business-hypermarket-carrefour-5b3302807dc0f9.6236099615300696325151
ABB_logo

Book a free 15-minute discovery call

Looking for support with your IT project?
Let’s talk to see how we can help.

Bartosz Michałowski

Head of Sales at Fabrity

The controller of the personal data is FABRITY sp. z o. o. with its registered office in Warsaw; the data is processed for the purpose of responding to a submitted inquiry; the legal basis for processing is the controller's legitimate interest in responding to a submitted inquiry and not leaving messages unanswered. Individuals whose data is processed have the following rights: access to data, rectification, erasure or restriction, right to object and the right to lodge a complaint with PUODO. Personal data in this form will be processed according to our privacy policy.

You can also send us an email.

In this case the controller of the personal data will be FABRITY sp. z o. o. and the data will be processed for the purpose of responding to a submitted inquiry; the legal basis for processing is the controller’s legitimate interest in responding to a submitted inquiry and not leaving messages unanswered. Personal data will be processed according to our privacy policy.

dormakaba 400
toyota
frontex 400
Ministry-of-Health
Logo_Sanofi
pepsico 400
bayer-logo-2
kisspng-carrefour-online-marketing-business-hypermarket-carrefour-5b3302807dc0f9.6236099615300696325151
ABB_logo