, ,

Supply chain on Ethereum Network


600 million people – almost every tenth in the world – fall ill every year with contaminated food, 420,000 of them die (cf. World Health Organization 2019). The main reason for this are supply chains that can not be properly traced back to the source of the contamination (cf. Yiannas 2018). Experts say that the blockchain technology is capable of reducing these numbers drastically by increasing traceability in the supply chain. That’s why we wanted to take a closer look at the implementation and benefits of blockchain technology in supply chain management. We decided to build a prototype of an app using ethereum blockchain. 

1 Introduction

The transparency of supply chains is one of the most important and most difficult to achieve improvement areas for logistics and supply chain management (cf. Abeyratne & Monfared 2016). Blockchain technology is seen in this context by logistics experts as “enormous potential” (O’Marah 2017), as “a much needed platform for economic renewal” (Casey and Wong 2017) and as “transformation of the supply chain and the way we produce, market, buy and consume our goods” (Dickson 2016). 

But why blockchain technology? In a typical transactional relationship, multiple parties are involved in transactions along a supply chain, and each party typically has its own version of the truth. This results in many errors, duplicates and redundancies. This is particularly true in the food sector, where there are many small and medium-sized businesses that still maintain paper-based records today. A single common general ledger that is tamper-proof mitigates many of these inefficiencies and allows all parties involved in the series of transactions to gain insight into the real data (cf. Yiannas 2018). According to Yiannas, there are four main factors of the technology that can provide more transparency in the supply chain: (1.) Decentralized: In a blockchain network, multiple nodes hold a copy of the same data, which eliminates the risk of a single point of failure in the network. This is a key difference between a blockchain network and a centralized repository of data. (2.) Unchangeable: Data is written onto the blockchain in a way that cannot be altered without detection. Thus, all stakeholders responsible for putting their data on the blockchain have to ensure the accuracy of their data. (3.) Consensus: Writing data onto the blockchain requires consensus from all parties involved in a transaction. This ensures that a single entity does not control the blockchain and also allows for the permissioning of data to meet the business needs of the blockchain participants. (4.) Democratic: The governance of the blockchain can be implemented in a democratic and transparent manner, whereby a diverse group of stakeholders participating in the blockchain network have an equal voice on issues such as data ownership, rights, data sharing, and protection. Therefore, all participants in a blockchain system can get smarter together (cf. Yiannas 2018).

On this premise, we considered which use cases of blockchain technology in supply chain management (SCM) seem relevant to us and which of these we would like to implement in our prototype. First of all, we identified the ability of blockchain, to increase traceability of the food supply chain. 600 million people – almost every tenth in the world – fall ill every year with contaminated food, 420,000 of them dying (cf. World Health Organization 2019). Tracking back the origin of food-borne outbreaks are a challenge for retailers. They need to get a quick overview of where the food comes from, understand which other products are affected and remove these from storage. Accurate tracing of contaminated food is often very complicated. An example: In June 2018, 210 people in the USA became infected with E. coli bacteria from contaminated lettuce. 96 persons were admitted to hospital, 27 persons developed a kind of kidney failure, five deaths were reported. It took about two weeks until the source of the bacteria was identified (Centers for Disease Control and Prevention 2018). Experts assume that a supply chain based on blockchain technology could drastically reduce the time required to identify the source (cf. Yiannas 2018). 

Walmart is one of the first retail groups in the world to integrate blockchain technology into its supply chain. More than 100 companies supplying Walmart with leafy vegetables need to enter detailed information about their food products into a blockchain database developed by I.B.M. for Walmart and several other retailers that examines similar measures to enable real-time end-to-end traceability (cf. Corkery and Popper 2018). 

Moreover, improved traceability of products is useful for the identification of counterfeit products. Counterfeit products are an increasingly relevant problem for companies and consumers. The startup Everledger tackles this problem with an alternative approach. To uniquely identify a diamond, 40 data points are stored in the publicly available records on the blockchain. Thus, potential buyers can clearly determine if the seller is the actual owner of the diamond and can also make sure they are not buying a “blood diamond” mined in a war zone (Underwood 2016). Another example is the medical sector, where counterfeit drugs are a known problem. Counterfeit drugs can even have lethal consequences if patients do not receive the treatment as prescribed (cf. Mackey & Nayyar 2017). Through a simple barcode or similar technologies, patient safety could be substantially improved by empowering the patient to check whether they received the actual drugs (cf. Mackey & Nayyar 2017).

In order to further increase traceability, Blockchain technology can also be used to implement Internet of Things. More and more logistics objects are equipped with sensors that generate data along the supply chain – e.g. on the status or temperature of a shipment. This data must be stored in an unalterable and accessible form. In addition, IoT devices connected to the Blockchain could also be provided with a digital currency, which enables them to interact autonomously with other parties and execute payments by themselves (cf. Christidis and Devetsikiotis 2016). Additionally, using digital currencies results in a few well known advantages like freedom to pay from anywhere and at anytime, quicker payments, more traceability, lower transaction fees and no involvement of any third parties (cf. Lee 2015).

We identified the problem, that humans do mistakes and at some point, wrong entries in the supply chain data will be written in the blockchain. This is still a main critic against the use of blockchain for supply chain management. Nevertheless, we found the topic very interesting and wanted to familiarize ourselves with it.

Given these advantages, we decided to build a prototype of an app that includes and visualizes them. Our aim was to create an app that retailers and buyers can use to sell and buy products through the ethereum blockchain.

Smart Contracts

In this article, our goal is to present a practical way of implementing a supply chain application based on a Ethereum blockchain. This application has been explored a lot lately on PoCs and huge companies are already experimenting with this opportunity for their operations. As stated above, Walmart is even already adapting a supply chain based on blockchain technology. Using blockchain results in the benefits of more transparency and efficient provenance tracking inherent to the technology.

Since this article intends to be simple and not a complete project, we will streamline the problem a lot. At the end of the project, however, we still have an end-to-end system that can demonstrate the applicability of the technology to this particular set of problems.

The Platform

Currently, there are a lot of platforms that allow you to make your own blockchain or use a public blockchain for your own projects, so we will leverage one instead of building from scratch. These projects have a lot of backing from players from both enterprises and the open source community, so we believe that using one is the most practical path for the majority of problems, allowing us to focus on the business logic instead of the infrastructure.

Currently there are a lot of platforms that allow you to make your own blockchain or use a public blockchain for your own projects, so we will leverage one instead of building from scratch. These projects have a lot of backing from players from both enterprises and the open source community, so we believe that using one is the most practical path for the majority of problems, allowing us to focus on the business logic instead of the infrastructure.

For our demo we chose the Ethereum Project. It is a popular platform and all the development tools available make implementation of solutions over it easy to accomplish.

Our objectives

We want to show you a simple Implementation of a Supply Chain. The szenario: A farmer wants to sell his products on the Blockchain. For this he creates an Item entry in our Decentral Application (short from: DApp). As soon as he has entered the necessary information, an entry will appear in the frontend.

An Item can have four states:

1. forSale
2. Sold
3. Shipped
4. Received

The initial status of an added Item will be set to 1 – ForSale.
If bought from a customer (e.g. a supermarket), the status will be changed to 2 – Sold.
The transaction amount will be transferred directly to the seller in ETH.
Now the farmer sends the goods – the status will be changed to 3 – Shipped.
When arrived, the supermarket will set the status to 4 – Received.
→ Now the trade is completed

Structure of the Ethereum smart contract

Let’s have a look a the basic structure of a smart contract written in Solidity.

pragma solidity >=0.4.24 <0.6.0;

import "./SafeMath.sol";

contract SupplyChain {
  //use SafeMath Method agaisnt Overflows
  using SafeMath for uint;

The contract file opens with a section on the applicable Solidity language version. Pragmas are known from compilers such as gcc. They give the compiler additional information on how to process the given code. This given pragma tells the compiler to use the ‘^’ highest available language version above ‘0.4.24’.

Furthermore, it is possible to import code from other files at the global scope level by using the well-known ‘import’ statement, just as in most other languages.

In this example we have added a SafeMath Method from OpenZeppelin to solve Problems like Overflow. This import makes the code less error-prone.

Tracking data structure

The following struct describes our simplified Item Asset which we want to track. Structs can be considered as a grouping of variables (Object literals without methods if you are coming from JS), which in essence give you a new type. The use makes sense if a set of variables can describe another variable with multiple instances.  

struct Item {
       string name;
       uint id;
       uint price;
       string creation_date;
       string location;
       uint state;
       address seller;
       address buyer;

In order to store the items, we created two mappings that allow us to store item properties as well as the relation between items and wallets based. To track the number of items, we added a Variable called “idCounter”.

  uint idCounter;
  mapping(address => uint) balances;
  mapping(uint => Item) items;
To define the contract owner we need the following line of code:
address public owner = msg.sender;

Declaring the events

For the four different States in our supply chain, we need a bunch of Events:

 event ForSale(uint id);
 event Sold(uint id);
 event Shipped(uint id);
 event Received(uint id);

 enum State {

Now we have to define conditions for our events with the help of modifiers. Modifiers are like a prerequisites check of the function. We want to choose the later price of the item in the Ethereum Unit ETH. Solidity selects values automatically in the smaller unit WEI. To convert this to ETH we have to multiply the value by *10^18.

//checks the addresses
   modifier verificationCaller (address _address) {
       require (msg.sender == _address);
//checks that the Value u entered to buy is enough
   modifier checkSum(uint _price) {
       require(msg.value >= (_price)*1e18);
//checks the Value u paid, if its to much u get the rest back

   modifier checkValue(uint _id) {
       uint _price = items[_id].price;
       uint refundAmount = msg.value - (_price)*1e18;
   modifier forSale (uint _id) {
       require(items[_id].state == uint(State.ForSale));
   modifier sold (uint _id) {
       require(items[_id].state == uint(State.Sold));
   modifier shipped (uint _id) {
       require(items[_id].state == uint(State.Shipped));
   modifier received (uint _id) {
       require(items[_id].state == uint(State.Received));

Set Constructor

Using the constructor we set the initial values at the beginning of the contract:

constructor() public {
       owner = msg.sender;
       idCounter = 0;

The first function that we would need is the “addItem” function. Here we set the values of the structs item. Within we set the idCounter + 1 for every item we create to make each item have its own id.

Declaring the functions

function addItem(string _name, uint _price, string _creation_date, string _location) public {
   emit ForSale(idCounter);
   items[idCounter] = Item({name: _name,
   id: idCounter, price: _price, creation_date: _creation_date, 
   location: _location, state: uint(State.ForSale), seller: 
   msg.sender, buyer: 0});
   idCounter = idCounter + 1;

Now we have to define the functions for the different Events:

// buy a Product
   function buyItem(uint id)
//Transfer to Farmer
       emit Sold(id);
       items[id].buyer = msg.sender;
       items[id].state = uint(State.Sold);
//ships a Product to its buyer
   function shipItem(uint id)
       emit Shipped(id);
       items[id].state = uint(State.Shipped);
//set Status to received
   function receiveItem(uint id)
       emit Received(id);
       items[id].state = uint(State.Received);

To get all the information of an item, we need a function that gives us the necessary values back:

//call funtion for all product infos
   function fetchItem(uint _id) public view returns (string name, uint id, uint price, string creation_date, string location, uint state, address seller, address buyer) {
       name = items[_id].name;
       id = items[_id].id;
       price = items[_id].price;
       creation_date = items[_id].creation_date;
       location = items[_id].location;
       state = uint(items[_id].state);
       seller = items[_id].seller;
       buyer = items[_id].buyer;
       return (name, id, price, creation_date, location, state, seller, buyer);

Finally, we need a function for the later frontend with which we can retrieve and list all items:

//Calls all Items
   function counterItems() public view returns (uint) {
       return idCounter;

Conclusion and outlook

In summary, we are very satisfied with the implementation of our project. We were able to implement the use case we wanted to display exactly as planned on the Ethereum blockchain. However, the familiarization with the general topic and functionality was more challenging than expected. The many bugs due to the early development stage of the developer tools and the lack of tutorials were another challenge. Nevertheless, the early stage of development was also a special motivation for us.

From our point of view, the blockchain technology is only partly recommendable for supply chain management. This is mainly due to the immutability of the inputs. We were aware of this problem, but given a process with no or very few human steps, the blockchain technology is definitely useful. The use case of the identification of counterfeit drugs convinced us in this context, because few human steps are necessary, IoT data can be automatically written into the blockchain and errors can be reduced. We therefore consider an adaptation of the technology in the pharmaceutical industry to be very likely in the near future.

Full project see Github


Abeyratne, S. A.; Monfared, R. P. (2016): Blockchain Ready Manufacturing Supply Chain Using Distributed Ledger. In: International Journal of Research in Engineering and Technology 5.9, S. 1–10.

Casey, M.; Wong, P. (2017): Global Supply Chains Are About to Get Better, Thanks to Blockchain. Harvard Business School Publishing. Online verfügbar unter: https://hbr.org/2017/03/global-supply-chains-are-about-to-get-better-thanks-to-Blockchain, zuletzt geprüft am 12.06.2019.

Centers for Disease Control and Prevention (2018): Multistate Outbreak of E. coli O157:H7 Infections Linked to Romaine Lettuce (Final Update). Online verfügbar unter: https://www.cdc.gov/ecoli/2018/o157h7-04-18/index.html, zuletzt geprüft am 12.06.2019.

Christidis, K.; Devetsikiotis, M. (2016): Blockchains and Smart Contracts for the Internet of Things. In: IEEE Access 4, S. 2292-2303.

Corkery, M.; Popper, N. (2018): From Farm to Blockchain: Walmart Tracks Its Lettuce. The giant retailer will begin requiring lettuce and spinach suppliers to contribute to a blockchain database that can rapidly pinpoint contamination. Online verfügbar unter https://www.nytimes.com/2018/09/24/business/walmart-blockchain-lettuce.html, zuletzt geprüft am 23.06.2019.

Dickson, B. (2016): Blockchain Has the Potential to Revolutionize the Supply Chain. Online verfügbar unter: https://techcrunch.com/2016/11/24/blockchain-has-the-potential-to-revolutionize-the-supply-chain/, zuletzt geprüft am 12.06.2019.

Hackius, N.; Petersen, M. (2017): Blockchain in logistics and supply chain: trick or treat? In: Proceedings of the Hamburg International Conference of Logistics (HICL), S. 3–18. DOI: 10.15480/882.1444.

Lee, David Kuo Chuen (Hg.) (2015): Handbook of digital currency. Bitcoin, innovation, financial instruments, and big data. Singapore: Elsevier Academic Press, S. 22-25.

Mackey, T. K.; Nayyar, G. (2017): A Review of Existing and Emerging Digital Technologies to Combat the Global Trade in Fake Medicines. In: Expert Opinion on Drug Safety 16.5, S. 587-602.

O’Marah, K. (2017): Blockchain For Supply Chain: Enormous Potential Down The Road. Online verfügbar unter: https://www.forbes.com/sites/kevinomarah/2017/03/09/blockchain-for-supply-chain-enormous-potential-down-the-road/, zuletzt geprüft am 12.06.2019.

Underwood, S. (2016): Blockchain Beyond Bitcoin. In: Communications of the ACM 59.11, S. 15-17.

Voigt, K.; Lackes, R.; Siepermann, M.; Krieger, W. (2019): Definition: Supply Chain Management (SCM). Online verfügbar unter https://wirtschaftslexikon.gabler.de/definition/supply-chain-management-scm-49361/version-272597, zuletzt aktualisiert am 12.06.2019, zuletzt geprüft am 12.06.2019.

World Health Organization (o. A.) (2019): Food safety. Online verfügbar unter https://www.who.int/news-room/fact-sheets/detail/food-safety, zuletzt geprüft am 12.06.2019.

Yiannas, F. (2018): A New Era of Food Transparency Powered by Blockchain. In: Innovations: Technology, Governance, Globalization 12 (1-2), S. 46–56. DOI: 10.1162/inov_a_00266.



, ,





Leave a Reply