How Do Ethereum Smart Contracts Work

smart contracts.jpeg

 

Most of us must have used the term ‘Smart Contracts’ in a blockchain discussion with colleagues or friends without completely realising the impact Smart Contracts can have on the entirety of the socio-economic framework our society thrives on.

We have mentioned multiple times in this blog that Blockchain as a technology is revolutionary.

We refrain from calling ourselves maximalists of any particular cryptocurrency. Rather, you may call us blockchain/crypto maximalists.

Coming back to the topic at hand, you may already know by now what Blockchain is and how it works. If not, feel free to read our previous blog posts. Now, let us delve into a more intriguing topic of what are smart contracts.

 

What are smart contracts

Quoting Wikipedia,

“A smart contract is a computer protocol intended to digitally facilitate, verify, or enforce the negotiation or performance of a contract. Smart contracts allow the performance of credible transactions without third parties. These transactions are trackable and irreversible.”

The above definition basically states that smart contracts as the name suggests are contracts that can be programmed, verified without third parties, are trackable and are immutable unless explicitly mentioned in the contract.

There are numerous blockchain platforms that let you create custom smart contracts for varied use cases. Some of them are Ethereum, Hyperledger fabric, R3 Corda, Stellar, Achain, etc.

 

How do smart contracts work

We will now try to understand smart contracts right from its inculcation.

Smart Contracts were first introduced by cryptographer and Computer Scientist Nick Szabo in 1994. A rough idea of smart contracts could be understood by analysing vending machines. You select a particular snack and enter the appropriate amount into the machine, the snack then presents itself to you. Just like that, magic.

However, sometimes the machine fails (mainly because of poor programming and centralisation), something which is tackled very efficiently when it comes to blockchain.

A Smart Contract needs several mathematical moving parts for it to function seamlessly.

  1. A Blockchain platform – for it to perform and verify transactions on chain
  2. Public Keys and Private Keys – the Smart Contract must have access to the private keys that it plans on controlling.
  3. Conditions – Clear conditions must be defined by the Smart Contract so that relevant transactions are carried out. (a simple if loop on the blockchain)

Smart Contracts are highly beneficial in a wide variety of domains as they let you create contracts that are secure, fast and are standardized for numerous use cases.

The use cases of smart contracts are so vast that we would probably need more than one post to elaborate on each of them. However, we will try to cover as much as possible in one post.

We will define this with 3 different examples that will adopt Smart Contracts in growing stages.

  1. Minimal
  2. Partial
  3. Complete

Let’s take a real-life scenario where smart contracts could possibly be used in the near future. In this example, we will consider Uber. Uber, as we all know, are disruptors of traditional taxis and are probably the largest cab hailing service in the globe. Smart Contracts potentially have the capability of disrupting this disruptive service.

 

Minimal

In this scenario, we will modify the payment system that Uber uses after completing a ride. You will ideally link your credit card to Uber which automatically deducts the fees when your ride completes.

If you do not prefer digital money, you will pay cash to the Uber driver based on the amount that shows up on your phone. Uber runs an algorithm that calculates how much fees should be charged to the rider based on the distance covered and the traffic/wait time.

Now, this can be completely automated if linked with a smart contract.

At the end of each ride, Uber will send a message to the smart contract linked with your profile and the appropriate amount gets deducted seamlessly. This use case is much similar to current day credit cards, however, Smart Contracts are more secure.

 

Partial

In the Partial scenario, we take the application of Smart Contracts up a notch and eliminate human drivers completely.

With the innovation Tesla, Uber and Google are doing on the grounds of self-driving cars, it isn’t long until you see self-driving private cars and cabs doing everyday rides on the freeway.

Now, imagine you book an Uber and it turns up to be a self-driving car. At the end of your ride, a Smart Contract can be programmed such that the fees charged are deducted directly from your crypto wallet and only after the payment of fees, will the doors of the cab open.

The Uber cab may have one or many owners and the fees will then get transferred to their accounts based on the logic written in the smart contract.

 

Complete

Now, this scenario is utopian and far-fetched but the possibilities of this happening cannot be outright denied.

In this scenario, an Uber is not owned by anyone but itself. The car in and of itself is a decentralised autonomous entity. This concept is adapted from ‘Internet of Money’ by Andreas Antonopoulos. (Highly recommended read)

Consider a self-driving car that has no owner. All the rides that it takes go towards the maintenance and fuel costs that it has to undertake. It saves the excess money for major upgrades or unforeseen circumstances.

But the car essentially has no owner and all the money it gets from rides can be used for varied purposes, all determined purely by the car on its own.

When you hail a ride from such a vehicle, at the end of each ride, the smart contract automatically deducts money from your wallet and sends it to the DAE (Decentralised Autonomous Entity), which is your Uber in this case.

The Uber then uses the same money for fuel or maintenance which again makes the use of Smart Contracts.

Uber or self-driving cars is one such example. You can put numerous transactions on the Smart Contract, including real estate transactions.

Smart contracts have use cases in everyday lives. Things you couldn’t imagine without the internet now; in the future, you wouldn’t imagine it without Smart Contracts!

Another real-life use case of Smart Contracts is how BBOD settles transactions on your Ethereum wallet.

We run a proprietary non-custodial smart contract using which you can trade on BBOD without transferring funds to the central wallet. Your funds stay safe in your very own Ethereum wallet.

We hope this blog post gave you a brief idea of how Smart Contracts work. In future posts, we will explore more in and around the blockchain ecosystem. Stay tuned!

 

Leave a Reply

Your email address will not be published. Required fields are marked *