Cold Chain Monitoring Tutorial

Weilei Yu
Weilei Yu
Dec 11, 2018 · 3 min read

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.

Image for post
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.

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

Streamr

Open source infrastructure for real-time data

Weilei Yu

Written by

Weilei Yu

Head of DevRel and Marketing at Flow blockchain. Prev Head of DevRel at Streamr. Vision driven and bias for action. Crypto enthusiast.

Streamr

Streamr

Own, publish & trade your data. Tech includes a pub/sub p2p Network, data Marketplace, & visualisation toolkit.

Weilei Yu

Written by

Weilei Yu

Head of DevRel and Marketing at Flow blockchain. Prev Head of DevRel at Streamr. Vision driven and bias for action. Crypto enthusiast.

Streamr

Streamr

Own, publish & trade your data. Tech includes a pub/sub p2p Network, data Marketplace, & visualisation toolkit.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store