Vending Machines on the Blockchain
When you read the title of this blog post, the probability is very high that you are confused. Where is the connection between a vending machine and the blockchain?
Vending machines exist since the 1880s and we are very thankful that they allow us to get important items like chocolate bars, lighters and pregnancy tests in the middle of the night when all shops are closed. In comparison to them, blockchain technology is very young, it exists since 2008. So, will you soon be able to get your snacks via blockchain? Yes, I am sure this will be possible in the future but this is not where I want to go in this post.
In this blog post, vending machines will be used to explain one of the most interesting applications of blockchain technology: Smart Contracts or how I prefer to call them Persistent Scripts. To explain what Persistent Scripts are and how they work I will compare them to a vending machine something we are all familiar with and can relate.
So what are Persistent Scripts? Let us start with the definition of my previous blog post: Persistent Scripts are pieces of code on a blockchain (blockchain programs), which automatically fulfill a task if certain pre-defined conditions are met. At first sight, this sounds very complicated. However, it is not and the vending machine will help us to understand its mechanism.
Actually, you are already familiar with this mechanism but not aware of it.
So how does a vending machine work? First, you choose your product of choice, pay the price and then the product is automatically released. A vending machine offers several benefits: The products can be purchases 24/7 there are no opening times, you do not have to hire somebody since it is automatic and you don’t have to trust your employees to be honest with you since (modern) vending machines have a memory of how many products were sold.
A Persistent Script works similarly. Let’s go back to my previous definition: it will automatically fulfill a task when certain pre-defined conditions are met. At this point, you should see the parallels to the vending machine. The vending machine works with the same principle. Only if you fulfill the pre-defined conditions of the vending machine like paying exactly two USD for a Coca Cola then the task will be automatically executed (releasing the bottle so you can take it).
Persistent Scripts and vending machines work both on if…/then… /else… principles: If two USD is paid then a Coca Cola will be released else no Coca Cola will be released. If 200 USD is paid then 200 tokens will be released else none.
Persistent Scripts have the same benefits of vending machines they work 24/7, reduce cost of labour and eliminate the need to trust (trustless trust). The difference is that due to the fact that Persistent Scripts run on a distributed ledger they have the benefits of the blockchain technology as to be immutable, tamper-proof, transparent and very secure which allows much more interesting use cases than vending machines will ever be capable (sorry).
Where can we use them? For example, a farmer can create a Persistent Script on the blockchain that if the temperature goes above 20 degrees then the sprinkler automatically will be activated on his fields else not. Or a medical IoT device like a pacemaker can be programmed that if the hearth beat is on a certain level then the pacemaker increases or decreases the pulse else not. Of course, you don’t need a Persistent Script on the blockchain for these two examples you can just create a “normal” program. The if…/then… /else… principle is not an invention of blockchain. However, putting these programs on a blockchain gives you several benefits. In the first example since Persistent Scripts can be immutable and transparent, the data can be used in a supply chain as proof of correct agriculture. In the second example having the data of a pacemaker on the blockchain makes it nearly impossible to hack and harm the patient which would be a lot easier on a central server.
In a world where everything becomes more digitalized and the number of IoT devices increases rapidly Persistent Scripts offer many use cases.
The farm example would not only save costs of labour but also make agriculture more effective resulting in a higher yield. Persistent Scripts have the possibility to change many industries, make processes more efficient and cut out many intermediaries that only act as trusted third parties.
Finishing this blog post you are now able to understand the connection between the classic vending machine and the game-changing Persistent Scripts on the blockchain. I want to add that there are still many obstacles before full implementation of Persistent Scripts in our daily lives like how to control if the conditions are fulfilled in the real world (oracle problem) or what if you need to change the Persistent Script after deploying it, to name just two of many issues that still need to be solved. Nevertheless, I believe that the blockchain & crypto community will be able to solve all these problems and bring us many benefits in our daily lives.
It is still a young technology though.