Ethereum

What Are Smart Contracts & How Do They Work

what-are-smart-contracts-and-how-do-they-work

WHAT ARE SMART CONTRACTS & HOW DO THEY WORK

How frustrating is it to be explaining crypto-stuff to your friends and they just don’t get it?

I will show you what smart contracts are and how they work in an easy to understand way.

Right off the bat, let’s straighten the two biggest misconceptions about smart contracts:

  • Smart contracts aren’t smart and they don’t have anything to do with artificial intelligence.
  • The majority of blockchains won’t run smart contracts because they can’t.

Let’s use the Ethereum blockchain to explain the concept.

That’s because this platform specializes in running complex, Turning complete smart contracts.

Note, that Bitcoin is the first cryptocurrency to use basic smart contracts. Their main use is to allow for peer-to-peer payments between its users. Although, it is worth mentioning that Bitcoin’s blockchain can’t use their full potential.

That’s due to its restrictive coding language.

Vitalik Buterin saw this as an opportunity to come up with something even better. That opportunity gave birth to the Ethereum platform which had one goal: handle smart contracts in a much better way.

Since we’re talking about inventing new things, let’s sprinkle a bit of history on the matter.

Nick Szabo invented smart contracts back in 1994. The rumor is that it’s the same person who invented Bitcoin. If you want to play a detective and solve the puzzle yourself, you can get more information here.

WHAT IS THE PURPOSE OF SMART CONTRACTS

Let’s discuss why people need traditional contracts in the first place.

The answer is simple.

They don’t trust each other.

The lack of trust between people that are to execute an agreement as required isn’t new.

For example, you wouldn’t trust your realtor to sell your house without a prior agreement with him, now would you? And how about if you never met the person you’re about to send money to on the Internet?

Smart contracts solve this problem, but what’s different?

WHAT IS A SMART CONTRACT

Smart contracts aim to provide the element of trust, too.

Yet, there’s a certain twist to them.

They’re not stacks of paper filled with legal and hard to understand language. That takes an army of lawyers to figure out what these papers actually say.

Smart contracts are the digital version of traditional agreements.

They are programs whose sole purpose is to legally bind whoever is participating. They’re lines of code written in Solidity.

That code is then compiled into “bytecode” and released to the blockchain as a smart contract.

Here’s a quick example of the code bare-bones of a smart contract:

contract Escrow {

address buyer;
address seller;
address agent;

function Escrow(address _agent, address _seller) {
// In this simple example, the person sending money is the buyer and sets up the initial contract
buyer = msg.sender;
agent = _agent;
seller = _seller;
}

  function release() {
if (msg.sender == agent)
suicide(seller); // Send all funds to seller
else throw;
}

  function cancel() {
if (msg.sender == agent)
suicide(buyer); // Cancel escrow and return all funds to buyer
else throw;
}
}

The above is an example of the Escrow smart contract written by Chriseth.

Because smart contracts are computer programs, here are a few examples of what you don’t have to do:

  • Waste money on hiring lawyers to represent you and fight your case
  • You don’t need to chase your realtor to release your funds when he sells your house
  • Chase the other person for money when you hold your side of the bargain

The good news is, the smart contract technology does it for you.

HOW DO SMART CONTRACTS WORK

In our example, that technology is the Ethereum blockchain. It uses Ethereum Virtual Machine (EVM) to process smart contracts.

The fuel (ether) is used to pay for the computing power of EVM to process and execute the contracts.

Note, that the processing fees are extremely minimal.

They simply don’t compare to centralized fees making the concept much more appealing.

The ideology behind smart contracts is simple.

They’re executed on the IF-WHEN-THEN basis, for example:

  • IF/WHEN you send me the item X, THEN the funds will be yours
  • IF/WHEN you transfer the money in full, THEN the item X be yours
  • IF/WHEN I finish the job, THEN the funds will be mine

These examples are basic, but they illustrate the point.

There’s no limit to how many IFs or THENs you include in your smart contract.

For example:

  • IF/WHEN you send me the item X and Y by date Z, THEN A and B by date C becomes yours etc.

I think you know what’s up by now. Let’s talk how you can use them in real life.

HOW DO YOU USE A SMART CONTRACT

Every contract has its own blockchain address. Once a smart contract is broadcast onto the network, you can interact with it by finding it through that address.

For example, you want $5 worth of Ethereum leave your wallet as soon as the person you’re transacting with does X.

Let’s call that person Vitalik and he’s gonna wash your car.

You don’t even have to be there to see him getting carried away with the sponges and foam. It’s no easy task, but he does a great job. Your car finally gets washed and Vitalik wants to get paid.

He goes to the Ethereum network, inputs the address and finds your contract. He then submits all required information to prove that he has in fact washed your car.

If the smart contract is happy with the provided evidence, the funds go to Vitalik’s wallet.

Now, I’m not sure whether the Ethereum boss would be happy to do it for this price, but you get the point.

You can specify as many conditions and requirements in your smart contract as you wish. The level of their complexity is virtually limitless.

This is what Ethereum does best and Bitcoin can’t.

That’s the main difference between these two blockchains.

Note, that smart contracts can also work together with other smart contracts.

This adds another layer of sophistication and depth to what you can achieve with them.

And that’s not even the most exciting thing.

The execution happens on the blockchain, thus it’s transparent, immutable, inexpensive and decentralized.

Welcome to the new era. The blockchain technology will be as normal to your kids as the Internet is to you right now.

WHY ARE SMART CONTRACTS GETTING POPULAR

There’re several key areas why smart contracts are superior to their traditional counterparts.

These smart contract benefits are:

  • Simplicity, speed of execution and real-time updates. The three differences making traditional contracts primitive
  • Redundancy of centralized entities and other middlemen that oftentimes contribute to risk increase
  • No middlemen to govern the transaction equals smaller fees and faster execution
  • Accuracy of self-execution means there’s no delay in delivering agreed incentives
  • Guaranteed transparency, certainty, safety and rightfulness of the process

HOW SMART ARE SMART CONTRACTS

As mentioned in the beginning of the article, the word “smart” has nothing to do with contracts being smart.

They can only perform basics calculations such as adding, subtracting, multiplying and dividing. Smart contracts aren’t designed to perform complex data analysis.

They don’t take into consideration new variables other than the ones specified beforehand.

The code isn’t interactive and you can’t fix it in real-time. This is one of the biggest worry when it comes to transacting through smart contracts.

THE DOWNSIDE TO SMART CONTRACTS

It’s impossible to stop a contract once it’s set to execute.

This could lead to severe consequences if the programs were misread or miswritten. There’s only one way to get back on track if a smart contract process go south.

And that’s by taking the traditional route – the court route. As of today, no better option is available.

This, however, is a no-brainer.

The idea of a self-executing court-like platform featuring decentralized Judge Judy pushes itself forward.

Now, you tell me how cool is that?

SMART CONTRACTS IN ACTION – EXAMPLES

Let’s have a look how smart contracts could contribute to improving our everyday life.

LIFE INSURANCE

You’ve heard the story several times throughout your life. No compensation in the event of death.

That’s the common practice of many insurance companies that we see on a daily basis. They’re almost always able to find a technicality that will prevent the pay-out.

You can solve this problem with the blockchain and smart contracts. It will be easy, simple and hassle-free.

MORTGAGES AND CREDIT SCORE

The process of buying or selling a house is long and tiresome, especially in the UK. It goes like this:

  • You are provisionally accepted for a mortgage;
  • You start looking for a property;
  • You view a few dozen of houses before settling on one or two…

Just to find out you can’t get the mortgage because of your credit score.

A smart contract would have ensured you were eligible in the first place. And it would have taken a second.

Besides, in the UK, it takes 36 days on average to get the keys to the house since the payment has cleared.

That’s due to the paper work that is sent back and forth between the buyer and the seller and their lawyers.

In today’s fast-paced world, that’s a waste of time and money.

You know what I’m about to say next. Do it through smart contracts and you’re literally gonna have more money and free time.

VOTING

You can use a smart contract to log votes on the blockchain.

For example, Donald becomes president as soon as it’s known that Hilary can’t get the majority.

It’s transparent and indisputable. Nobody and nothing can question it. Not even Russian hackers!

PEER-TO-PEER TRANSACTIONS

As mentioned, Bitcoin’s transactions are based on simple smart contracts.

This is already a proven method of transferring funds that will only become more popular.

This, however, could expand into decentralized lending services, such as:

  • mortgages
  • personal loans
  • business loans
  • credit cards

The services would run on smart contracts with one significant difference.

The cost would be based on interests only making them approx. 7x cheaper than they are today.

That’s due to administrative costs and insurance (which is not required on blockchain).

CONCLUSION

Smart contracts aren’t perfect and they still need work.

Whether it’s their usability or practicality, there’s always room for improvement. Yet, they’re already proving to be a much better option that the traditional contracts.

And that’s pretty much when it comes to anything you can think of.

They put you behind the wheel of your personal and professional affairs.

All known centralized entities become obsolete.

To be clear, it doesn’t mean that those lawyers and realtors from our examples will lose their jobs. Their markets won’t shrink and that’s not the case.

Think outside the box.

It’s the dynamic of the process that will change for the better.

You will be able to get things done quicker and cheaper. But you’re still gonna need your realtor to find you buyers and a lawyer to represent you.

Smart contracts will revolutionize the world.

The question is, will YOU join the mix?

Click to comment

Leave a Reply

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

To Top