{[{item.pair.split("_")[0]}]} ${[{item.price.toFixed(4)}]}



What are smart contracts in blockchain?

smart contracts in blockchain

April 28, 2021 | 

JOHN K MWANIKI |  0 Comments| 



Get Into Cryptocurrency Trading Today

Let's say you are hungry and craving a granola bar. You could go to a shop or supermarket, select it from a shelf, run it by the cashier then get your bar. Alternatively, you could go to a vending machine that stocks the same bar, put your money in and select the bar and get it in the slot. Here, the cashier at the shop is an intermediary. A smart contract is like a vending machine, only its code. It enables parties to execute agreements automatically while eliminating the need for a third party. 

Here's an example. Jane operates a fabric importation business. She wants to buy clothes from a new company, but she is not entirely sure if she should trust them. They, therefore, agree to get a smart contract written which specifies the conditions by which the company will be paid. They agree that the moment the shipment arrives at a particular destination, an IoT tracking device in the shipment will execute the contract and pay the company. This takes the element of trust entirely out of the business transaction as if the clothes don't get to the set location, the company doesn't get paid.

How does it work?

There are four important parts that work together in a smart contract;

  • The parties who want to agree on something

  • The smart contract - a line of code containing the conditions of the agreement

  • The blockchain network. The smart contract is written on the blockchain, and

  • The oracle - a real-time data feed or API

First, two parties that want to agree on something come together and agree on the stipulations of this agreement. For example, let's use the example of Jane and the textile company. Jane wants the clothes delivered to her on a particular date. The delivery of the products and the date can be added to the contract. Maybe the business wants to receive a deposit as soon as the clothes leave the airport. This, too, can be written into the smart contract. Smart contracts operate on conditional bases, for example, if A then B or when A then B.

The two parties can explore all possibilities and exceptions and have them added to the contract, which will be written into the blockchain network. Once the oracle sends information that a certain condition has been met, the smart contract will execute the contract in line with the agreement. For example, once the tracking device on the package shows that it's in the air, the contract can send the company the deposit. If the package never arrives to Jane, the rest of the money will not be disbursed to the company. 

All smart contract transactions are recorded on the blockchain ledger. This means that they cannot be tampered with or deleted. 

Benefits of smart contracts

There are several benefits of smart contracts, including;

a.    Autonomy 

Using data feeds, smart contracts can operate without the need for any third party. Where Jane would have needed escrow services to perform the same function, she is using a self-executing contract.

b.    Trust 

Smart contracts make the process trustless. You don't need to trust each other to work together. 

c.    Safety

Thanks to encryption on blockchain, it is possible to execute your transactions while remaining anonymous as transactions are stored under pseudonyms on the ledger. This makes it possible for people to work with businesses anonymously. 

d.    Backup

Because all transactions are stored on the ledger, it is nearly impossible to go back on the agreement. Only a 51% attack would enable an entity to change transactions on a ledger. 

e.    Speed

When working with intermediaries, they need to collect data, verify it, and then they can execute the contract. The smart contract executes immediately it receives the data with no need for verification or delays.

f.    Savings

Because you have eliminated the intermediary, you would save money and time. 

g.    Accuracy

It is possible for people to make errors when writing or executing contracts manually. However, unless there is a bug in the contract or it receives faulty data, it is nearly impossible to make errors with smart contracts. 

h.    Transparency

All transactions made are recorded on the ledger, meaning it is impossible to make any unauthorized transactions. 

Limitations of smart contracts

It would be nice to assume that smart contracts are faultless, but there are some limitations you may need to note;

a.    Bugs in the code

While the execution of the contract may be almost perfect, the codes of the contracts are written by developers, and it is possible for them to make errors when writing the code. These errors could easily lead to the wrong execution of the code. 

b.    Legal and regulatory enforcement

Smart contracts have no clear legal status as they are written in code. It may therefore be hard to enforce such an agreement. For example, let's say they designed a smart contract to pay a particular person a specific amount every month. However, your agreement with them ends, but the contract still pays them. It would be difficult to go to court and have them pay you back. 

c.    Transactions are irreversible

It's not possible to reverse recorded transactions. So, if Jane finds out that she received the wrong clothes, she would not be able to reverse the transaction once executed. The company would have to send the money back, which is a new transaction entirely.

d.    The oracle problem

As was mentioned, an oracle is an infrastructure that enables contracts to use information from outside the blockchain. The oracle problem refers to the fact that it is hard to verify the authenticity of data from oracles, bringing the truthfulness of the execution of smart contracts into question. 


Smart contracts are executable lines of code written on blockchain networks that automatically execute when predetermined conditions are met. There are very common on the Ethereum network but are seeing adoption on other blockchain networks as well. The applications of smart contracts are vast, from the execution of insurance policies to streamlining the chain of supply systems. One can only expect their mainstream adoption in the future. 

Buy & Sell Cryptocurrency Instantly




Like this article





Market Cap {[{ marketcap }]}






{[{ item.pair.split('_')[0] }]}

${[{ item.price }]}

{[{ item.change24 }]}

{[{ item.change24 }]}


Showing {[{ showing }]}

Market Cap {[{ marketcap }]}






{[{ item.pair.split('_')[0] }]}

${[{ item.price }]}

{[{ item.change24 }]}

{[{ item.change24 }]}


Showing {[{ showing_trend }]}