Simply stated,

A smart contract is some software code that transfers assets between parties when certain conditions occur.

That is a very simple explanation but let’s dive deeper into what it really means, what it looks like and how it works.

What it means?

Smart contracts were brought to light in the mid 90’s and cryptographer Nick Szabo is generally credited with “inventing” smart contracts. The reason it has gained significant momentum now is because of the invention of bitcoins, the most successful digital currency to date and the underlying framework it provides.

In a sentence, contracts are agreements between parties. Smart contracts are agreements between parties in the digital realm.

A more formal definition of a smart contract is:

a computer program that directly controls the transfer of digital currencies or assets between parties under certain conditions. It not only defines the rules and penalties around an agreement in the same way that a traditional contract does, but it can also automatically enforce those obligations. It does this by taking in information as input, assigning value to that input through the rules set out in the contract, and executing the actions required by those contractual clauses. These contracts are stored on blockchain technology, a decentralized ledger that also underpins bitcoin and other cryptocurrencies. Blockchain is ideal for storing smart contracts because of the technology’s security and immutability.

What it looks like?

Smart contracts became popular when Ethereum was created. Users could utilize the javascript like programming to create all sorts of smart contracts. Here is a snippet of an Ethereum smart contract for a crowdsale.

It is essentially saying that if you give the smart contract some ether (ie money), you will automatically receive tokens that may represent shares. The advantage of the smart contract is that the contract itself is not controlled by any 3rd party meaning you don’t have the trust issue. The code should be open and transparent and it is also distributed and immutable.

In bitcoins

Many people also look over the fact that bitcoin makes use of smart contracts.

scriptPubKey:<OP_2> <A pubkey> <B pubkey> <C pubkey> <OP_3> <OP_CHECKMULTISIG>
scriptsig:<OP_0> <sig A> <sig C> <redeemScript> <OP_HASH160> <redeemScriptHash> <OP_EQUAL>

Here is an example of how bitcoin programs a “smart contract” so that 3 people have contributed (first line) but only 2 people are required to spend from it (second line script sig).

The point is that smart contracts were enabled in bitcoins before Ethereum. What Ethereum did was expand the scope of it’s use to address the new challenges that arose.

How it works?

There are 3 characteristics of smart contracts.

  1. The code (of the smart contract)
  2. The distributed ledger (where the smart contract lives)
  3. Execution of the contract (to verify the rules and achieve consensus)

Vending Machine

Some people use a vending machine as an analogy. The vending machine has a smart contract programmed into it that says if the correct amount of coins are inserted, release the drink that the user selected and refund the change if required. Obviously the principles are the same but the underlying framework is different. ie it is not using distributed ledger technology (DLT).

Another example

Another application is if I wanted to sell electricity to my neighbor. I could measure the usage in watts each day at midnight and automatically withdraw the amount in bitcoins from the smart contract as micro payments. My neighbor would continue to feed bitcoins into the smart contract but could also place a maximum daily withdraw restriction. This restriction could also then allow the smart contract to turn off the power as well.

Summary

In summary, smart contracts are just pieces of software code that is written to perform some exchange of value between parties with various rules or agreements in place. The key is that it is decentralized (not need to trust a 3rd party) and distributed, open and immutable.

References:

  • https://bitsonblocks.net/2016/02/01/a-gentle-introduction-to-smart-contracts/
  • http://searchcompliance.techtarget.com/definition/smart-contract

Leave a Reply

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