Now Reading
Introduction to smart contracts: The vending machines of the blockchain.

Introduction to smart contracts: The vending machines of the blockchain.

Vending machines are fascinating. Have you ever wondered how vending machines work? Once you put in your payment, you get your candy bar or soda automatically without the need for the intervention of a human.

There’s an underlying software that enables this process. The computer behind the vending machine notes whenever certain conditions like the choice of drink and payment are met; it then takes action and releases the drinks. 

Smart contracts work just like vending machines.

A smart contract is a group of computer code that has been written to automatically execute an action whenever a set of criteria is met.  

It is like any other contract that establishes the terms of an agreement in a transaction. Smart contracts are called smart because they are a set of preset rules and regulations that are written into lines of programming code instead of paper in an office.

Smart Contracts work like vending machines

Let’s take another scenario. You and your friends start a business together, and you agree that none of you will make a profit from the business for the next five years. We’ll assume that you make an average of $10,000 in profit monthly. 

So you set up a direct debit (automatic withdrawals from the account) for the business account. The direct debit enables another app to take $10,000 from the account every month for safekeeping. 

Every month, as far as there is $10,000 in that account, the debit transaction will happen without fail. That’s how smart contracts work. They execute actions as long as the basic criteria are met.

Origin of smart contracts 

The concept of smart contracts was first proposed in 1994 by American computer scientist, Nick Szabo. Szabo was responsible for the invention of a virtual currency called “Bit Gold” in 1998, ten years before the invention of Bitcoin, the most popular cryptocurrency. 

Popular billionaire and crypto investor Elon Musk even recently alleged that Szabo could be Bitcoin’s anonymous inventor, Satoshi Nakamoto. A claim he has since denied. 

Mr Nick Szabo at a conference.

Szabo described smart contracts as computerised transaction protocols that execute the terms of a contract. He wanted to improve the functionality of electronic transaction methods, such as POS (point of sale).

Szabo was ahead of his time as most of his predictions are now being used in the blockchain and cryptocurrency industry.

How smart contracts work

Smart contracts have become increasingly popular today as they are used on numerous blockchains, with Ethereum the first to deploy one. 

They serve as the middlemen in decentralised transactions in the blockchain. They are preferred in blockchain technology because, unlike human beings, there is no chance of bias or favouritism. 

Smart contracts follow an “if/when…then” concept. It means most smart contracts work like this: If or when this happens, then this should be done. 

When a transaction happens between two parties on the blockchain, the smart contract serves as an escrow (third party); it holds the payment until both parties meet the preset conditions.

Let’s say you want to buy a coin on the blockchain. The smart contract receives the money you pay and also receives the coin from the seller. Only then do you receive the coin you’ve paid for, and the money you paid gets to the seller. 

How a smart contract is created

To build a smart contract, all the parties involved must come together to agree on the features which they want it to have and how it will be deployed based on certain conditions. 

The actions deployed by smart contracts can be payment authorisation, token distribution, and transaction recording. 

After the smart contract has been built, the logic behind it is tested repeatedly to avoid any loopholes that can lead to disasters in the future. If the code passes the internal test, it is then sent to an external firm or expert to check for feasibility and security.  

If the tests have a positive result, the smart contract is deployed on an existing blockchain. 

Uses of smart contracts

Smart contracts can be used for many things, including financial transactions, transportation, and other services. 


Smart contracts enable easy payments on decentralised systems like the blockchain. They allow people to transfer money freely because they know their money won’t be disbursed without receiving what they paid for. It works the same for sellers. 


Smart contracts make it possible for elections to be 100% transparent. If smart contracts are written to handle the election process, the possibility of voter count being altered would be zero to none. It will also make it easy for votes to be counted.


Smart contracts make it easy for crypto users to lend and borrow money on the blockchain. Lenders do not have to worry about getting their money back. The software will automatically credit their accounts with the initial amount plus interest once the agreed time is reached. 


Smart contracts can help to keep lifetime records of patients. The records would be accessible to certain individuals via a private lock or password. It can be shared with new doctors to prevent delays due to new testing and also with insurance companies as proof of service. 

Benefits of smart contracts

Transparency and trust

Smart contracts are created in such a way that it is available to the public but still very secure. The code that makes up a smart contract is available online, but it cannot be altered without the agreement of its creators. 

You also do not have to worry about human bias because the process only involves pure computer logic. 

Speed and efficiency

Unlike humans, computers are very fast and efficient when validating and verifying transactions. That’s literally why they were built, to carry out functions. 

Whenever the conditions of an agreement are met, the smart contract executes immediately. Smart contracts are also digital, so there is no delay involved, like vetting paperwork and reviewing documentation.

Safety and security

Smart contracts are usually encrypted, making them hard to hack. They can only be breached via loopholes like spelling errors or mistakes in the calculation. That’s why developers are advised to extensively test their code before publishing it on the blockchain. 

As blockchain technology evolves, smart contracts are at the heart of the industry, running tasks, deploying rewards, and enforcing punishment to defaulters. They are the lifeblood of the technology and can be utilised to do so much more than they are being used for. 

© 2022 RuptHQ. All Rights Reserved.

Scroll To Top