Sharing Immutable Information Between Companies

Matheus Leal
The Startup
Published in
7 min readFeb 16, 2021

--

This article aims to propose a solution using the permissioned network Hyperledger Fabric for sharing immutable information between organizations. Companies from all over the world invest heavily in innovation to create answers to the needs presented in the market. In a corporate context, the transaction of information in a secure and inviolable way can be incredibly valuable.

World Connected by Companies - Retrive from pngitem

Stimulus

The use of blockchain in companies nowadays goes far beyond cryptocurrencies. Many organizations are already experimenting with blockchain innovations to fulfill a range of needs. Companies like Walmart are using blockchain technology to track shipments from their suppliers and reduce the risks of food spoilage and contamination. Seagate is using the technology to catch and prevent impostors, and Metlife can now, for example, pay claims instantly to future mothers who test positive for gestational diabetes.

Blockchain is a decentralized database that stores a history of assets and transactions between computers on a network. This technology allows for almost instant data storage and sharing. In the case of digital currencies, its use serves to record the transactions made and store them in a network of computers. Different types of data can be stored and shared, allowing multiple solutions using blockchain.

As blockchain gains publicity, large corporations and startups are exploring uses of the technology outside of the financial services industry. In this supply chain context, the transaction of information in a secure and inviolable way is relevant. Companies can share information that helps both their growth and cost. A blockchain can help companies record and share relevant information to more effectively manage the supply chain. A public network may not be the most secure solution for this project. This article aims to propose a solution using the permissioned network Hyperledger Fabric for sharing immutable information between companies.

Public vs Private Blockchain

Blockchain is a network that works with connected blocks through a hash that guarantees the security and immutability of information. Blockchain has evolved over the past few years in multiple types. We currently have two commonly used types: public and private networks.

A public blockchain is permissionless. Anyone can join the network and read, write, or participate within the blockchain. A public blockchain is decentralized and does not have a single entity that controls the network. One of the disadvantages of a public blockchain is the substantial amount of computing power required to keep a book distributed on a large scale. The biggest examples of private blockchain are Bitcoin and Ethereum.

A private blockchain network requires an invitation and must be validated by the network initiator or a set of rules established by the network initiator. This feature is ideal for companies. This allows them to set up a private blockchain with the permissioned network, that is, only people with permission can participate in that network. Despite making it much less decentralized than a public blockchain, it allows for transactions between companies that do not necessarily have trust with each other. The access control mechanism of a private blockchain can vary:

  • Existing participants can decide future participants
  • A regulatory authority could issue licenses for participation
  • A consortium could take decisions

Once an entity joins the network, it will play a role in maintenance in a decentralized manner. The biggest examples of private blockchain Hyperleadger Fabric and Corda.

Public and Private Blockchain Diagrams — Retrive from zephyrnet

It is worth mentioning that although different, they have some similarities between them. Both are decentralized peer-to-peer networks, in which each participant maintains a replica of a shared ledger(node). Furthermore, in both cases, through a protocol known as consensus, it is possible to provide certain guarantees about the immutability of the ledger even when some participants are defective or malicious.

Hyperleadger

To share immutable information between companies we used Hyperledger as our Blockchain provider. This collaborative project involving several industries currently incubates and promotes a variety of blockchain business technologies. We can divide these projects between frameworks, tools, and libraries. Within the frameworks, we can highlight that everyone seeks to operate around four requirements: private transactions, identity, suitability, interoperability, and portability. We can highlight the following:

  • Hyperledger Sawtooth: modular blockchain suite developed by Intel, which uses a new consensus algorithm called Proof of Elapsed Time (PoeT).
  • Hyperledger Fabric: this project is led by IBM. Fabric is a plug and performs the implementation of blockchain technology designed as a basis for developing high-scale blockchain applications with a flexible degree of permissions.
  • Hyperledger Burrow: develops a permissible smart contract machine along with the Ethereum specification.

In addition to these framework projects, Hyperledger has several tools to facilitate and make blockchain access and development more effective. There are several currently being developed, among which we can highlight the following:

  • Caliper: a blockchain benchmark tool, which allows users to measure the performance of a specific blockchain implementation with a set of predefined use cases.
  • Explorer: a tool to view, deploy or query blocks, transactions and associated data, network information, chain codes and transaction families, as well as any other relevant information stored in the logbook.

Hyperledger has libraries that provide a shared, reusable, interoperable tool kit designed for initiatives and solutions focused on Blockchain. There are several currently being developed, among which we can highlight the following:

  • Quilt: offers interoperability between accounting systems through the implementation of the ILP, which is a payment protocol and is designed to transfer value between distributed and undistributed books.
Hyperledger Greenhouse — Retrive from Hyperledger

Various blockchain technologies are being developed within the Hyperledger greenhouse. All projects are open source, which means that you can download and use the software free of charge without joining Hyperledger. For more information please access the official website.

Implementation

Our goal is to show a solution for sharing information between companies in a transparent and inviolable way. For that, we will show a service based on the Hyperledger Fabric. End-users interact with the blockchain ledger by invoking smart contracts. In Hyperledger Fabric, smart contracts are deployed in packages referred to as chaincode. Organizations that want to validate transactions or query the ledger need to install a chaincode on their peers. After a chaincode has been installed on the peers joined to a channel, multiple organizations can use the smart contracts in the chaincode to create or update assets on the channel ledger.

// SmartContract provides functions for managing an Assettype SmartContract struct {    contractapi.Contract}// InitLedger adds a base set of assets to the ledgerfunc (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface) error { ... }// CreateAsset issues a new asset to the world state with given details.func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, owner string, segments []string) error { ... }// ReadAsset returns the asset stored in the world state with given id.func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, id string) (*Asset, error) { ... }// UpdateAsset updates an existing asset in the world state with provided parameters.func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface, id string, owner string, segments []string) error { ... }// DeleteAsset deletes an given asset from the world state.func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface, id string) error { ... }// AssetExists returns true when asset with given ID exists in world statefunc (s *SmartContract) AssetExists(ctx contractapi.TransactionContextInterface, id string) (bool, error) { ... }// TransferAsset updates the owner field of asset with given id in world state.func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterface, id string, newOwner string) error { ... }// GetAllAssets returns all assets found in world statefunc (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]*Asset, error) { ... }

The structure defined in this example consists of a transaction ID, the name of the owner and segments of information to be stored:

// Asset describes basic details of what makes up a simple assettype Asset struct {    ID string `json:”ID”`    Owner string `json:”owner”`    Segments []string `json:”segments”`}

We will start by deploying an instance of the Fabric test network. Before you begin, make sure that that you have installed the Prerequisites and Installed the Samples, Binaries and Docker Images. Use the following command to navigate to the test network directory within your local clone of the fabric-samples repository:

$ cd fabric-samples/test-network
$ ./network.sh up createChannel

The createChannel command creates a channel named mychannel with two channel members, Org1 and Org2. The command also joins a peer that belongs to each organization to the channel. After that, you will need to execute a few more commands to be able to interact with your smart contract. These commands can be followed through the official documentation or in this summary.

Conclusion

This article aims to propose a solution using the permissioned network Hyperledger Fabric for sharing immutable information between companies. Fabric is a plug and performs the implementation of blockchain technology designed as a basis for developing high-scale blockchain applications with a flexible degree of permissions. The structure defined in this article consists of a transaction ID, the name of the owner, and segments of information to be stored. With this structure, member peers may share information. By doing so companies can share information that helps both their growth and cost.

--

--

Matheus Leal
The Startup

M.Sc at Pontifícia Universidade Católica do Rio de Janeiro & Applying DevOps culture at Globo