Cold Chain Monitoring Tutorial

Video Script

In this tutorial I will be covering two main aspects:

  • How to deploy smart contracts on the Ethereum public blockchain. (We will be using Ethereum Rinkeby testnet where we can get free test ETH.)
  • How to handle high volume, real-time data streams and create triggers to interact with smart contract functions in more automated way. I will be using a demo we have created, called “Cold Chain Monitoring”, to showcase this scenario.

This demo is built around the use case of a transportation company servicing refrigerated goods. We want to give clients a solution to monitor the condition of their products during the journey in real time. But this is not just about passive monitoring. They will also be able to set penalties in case the temperature inside the truck goes above a certain threshold.

The goal is to protect the frozen food from spoiling, get partial refund if this happens and disincentivize bad behavior in doing so. And these penalties can be automatically paid out using pre-agreed smart contracts, saving time and money for all parties.

Cold Chain Monitoring Tutorial
Wei Yu, the Streamr project’s head of DevRel, at the Web3 Summit in Berlin in October teaching others how to get involved in the tool stack

Streamr can handle large volumes of real-time data off-chain. It also permits interaction with on-chain Ethereum smart contracts via event triggers. Similar setups can be used for many industries, including airline applications leveraging blockchain. For example you could create a real-time data stream of flight arrival/departure schedule and trigger automated partial refunds for late flights. This could turn negative customer experiences into positive ones for airlines. Now let’s start by taking a look at the smart contract that we have prepared beforehand. This is a simplified version that contains the essence of what we are trying to achieve in this demo. You can find the repository containing both this simplified version and a more complete one at this link.

Contribute to streamr-dev/iata-hackathon-2018 development by creating an account on

In this contract there are five main points to pay attention to:

  • We have setup this contract with the assumption that the customer (the one paying for the shipping) is the one deploying it and is the entity that sets the initial parameters like temperature limit, penalties etc
  • This smart contract takes advantage of a special feature of ERC20 token standard called allowance. This feature allows an account A to give permission to a separate account B to spend up to a certain set amount without having to request approval each time.
  • The shipping company is the Service Provider who can accept the shipping order once the contract has been deployed
  • Streamr canvas Ethereum address is considered as a neutral third party that will trigger the automated payment distribution and penalties applied at end of delivery
  • We are using an ERC20 standard token as means of payment for this contract

See video for the full tutorial

Stay up to date

Get the latest Streamr news and articles delivered to your inbox