Introduction to Smart Contracts

in #smart-contracts8 years ago

Introduction to Smart Contracts


I will try here to introduce to the average person the concept of smart contract as it was explained by brilliant enthousiats.

What is a contract in essence ? A voluntary arrangement between two or more parties. Smart contracts on the other side are computer protocols that facilitate, verify, or enforce the negotiation or performance of a contract, or that make a contractual clause unnecessary. Smart contracts usually also have a user interface and often emulate the logic of contractual clauses.

That was wikipedia’s answer but … What in the hell did that mean ?

To put it as simply as possible, the term ‘smart contract’ can refer to any contract which is capable of executing or enforcing itself.

Smart contracts are written as programming code which can be run on a computer rather than in legal language on a printed document. This code can define strict rules and consequences in the same way that a traditional legal document would, stating the obligations, benefits and penalties which may be due to either party in various different circumstances. But unlike a traditional contract it can also take information as an input, process that information through the rules set out in the contract, and take any actions required of it as a result.

Simple really ?

In the real world, the ownership of a car isn’t solely decided by who’s holding the key. Living in the United States, Bob has to register his car with the Department of Motor Vehicles (DMV). Therefore, when he wants to sell his car to Alice, besides exchanging the key and money, they also have to work with the DMV in person so that the DMV can appropriately update their database.
Does it sound like a lot of work to you? It does to me. Now, imagine in an ideal and completely decentralized world, everyone including Bob and Alice has their own key fob, which is the equivalent of a Bitcoin wallet. The smart car is designed such that it can hold and constantly download new blocks of the full blockchain. When it is being assembled, a special transaction is created to assign the car to the public address of the manufacturer’s key fob. The transaction ID is then hard-coded into the car’s system.
So how can we transfer the car ownership to Bob if he buys it from the manufacturer? Easy: the manufacturer can just create a new transaction with the genesis transaction as the input and the public address of Bob’s key fob as the output. Now, with the updated public key on the blockchain, every time Bob wants to open the door and start the car engine, he can just send a request to the car. It will send back a challenge to Bob, which he has to sign with his private key. Because the car knows the public key of its authorized owner, it is easy to verify Bob’s key fob, while it’s virtually impossible for strangers to reverse-engineer his private key just based on the public key on the blockchain. This process is pretty safe thanks to cryptography.
Similarly, when Bob decides to sell the car to Alice, he simply creates a new transaction to be broadcasted to and verified by Bitcoin miners all around the world. The deal can be closed within one hour after six confirmations on the blockchain, without either Bob or Alice having to go through time-consuming procedures with the DMV or any other centralized organization. What is even more interesting is that there’s no single key fob being passed around. Everyone already has their permanent key fob; the only thing that needs to be updated is the blockchain.

Well how does it applies apart from cars ?

Here is a short list provided by Dean Walsh on :

http://cryptorials.io/

Breach Prevention:

An early and fairly simple example of a smart contract is Digital Rights Management or DRM technologies. This type of contract does not take or process inputs, but simply enforces itself by making it impossible for you to break the contract by acting in an unauthorised manner – for example by copying music or video file which is protected by copyright.
Property Law: Cryptocurrencies such as Bitcoin can be thought of as a set of smart contracts which enforce property law. Cryptographic techniques are used to ensure that only the owner of a digital token such as a bitcoin can spend it. Several decentralized asset exchanges already exist, which broaden out the range of asset so that many different digital assets can be traded on a single block chain. The same principle can also be extended to physical products with electronic controls or embedded microchips.
Financial Services: Cryptocurrency obviously opens up a wide range of different use case for smart contracts which wouldn’t otherwise be possible. For example, systems such as the one used by BurstCoin are able to run auctions which automatically check for the highest bidder within a set time limit and refund everyone else, automatically transfer dormant funds, or run a decentralized lottery. This kind of smart contract only takes very simple numerical values as inputs, performs purely mathematical evaluations, and outputs a financial transaction through a cryptocurrency protocol. Another example would be Bitshares’ pegged assets, the creation of which by traders requires collateral to be put into a contract which has the power to sell that collateral if the market moves against its owner.

Credit Enforcement:

An extension of property law, and a classic example of how smart contracts can be used in the real world, is credit agreements which disable your product if you fail to make your repayments. For example, you might imaging a future in which you buy a new car on credit, you fail to make the repayments, and your car simpy locks its doors and drives itself back to the showroom. Most electric products could be fitted with a ‘kill switch’ which disabled them if a simple condition is not met – such as a payment being made through a public channel such as a cryptocurrency blockchain.

Oracle contracts:

The main limitations to what can be done with smart contracts is that a computer program cannot easily and reliably tell what is happening in the physical world or who is telling the truth. Checking whether a bitcoin payment has been made is a simple task which is suitable for a computer program to do, but most real-world contracts and situations (for example: was a product really delivered to someone? Did a freelancer deliver work that met the company’s stated requirements?) are much harder for a computer program to evaluate. A smart contract’s execution is only as good as the inputs it takes in, and it may be difficult to find inputs which are sufficient to the job which both parties trust. One solution to this is to have oracles – online services providers whose job is to broadcast data which can be used as inputs by smart contract makers. For example, an oracle may broadcast new entires on the government registry of deaths, to be used by contracts executing wills, or the results of a football match, to be used in settling gambling bets. This method is used by Ripple’s Codius smart contracting platform

Double Deposit Method:

Some of the first working examples of smart contracts in the realm of cryptocurrency used the double deposit method pioneered by BitHalo and BlackHalo. This deceptively simple, but still very powerful method, is ideally suited to use with cryptocurrency. When entering into a contract such as this each person is required to make a cryptocurrency deposit into the contract’s program. This program has a set time before it expires. If the people involved in the contract cannot come to an agreement over how to proceed before the contract expire the funds are ‘burned’ – which means sending them to an address which nobody knows the private key for, effectively making them unspendable. The program itself doesn’t, therefore, make any attempt to decide whether each party has lived up to their obligations or who should do what to fulfill the terms they agreed to. But what it does do is to make it impossible for anybody to make a profit by cheating the other person – by ensuring that by breaking the contract they stand to lose exactly as much as they could gain. It also pushes all parties to put maximum effort into dispute resolution to comes to an agreement everyone can accept before the timer runs down and their funds are burned.

Nine misconceptions about smart contracts:
  1. Smart contracts are the same as a contractual agreement
    No. If we stick to Nick Szabo’s original idea, smart contracts help make the breach of an agreement expensive because they control a real-world valuable property via "digital means".
    So, a smart contract can enforce a functional implementation of a particular requirement, and can show proof that certain conditions were met or not met.
    These can be fairly strict implementations, eg if a car payment is not made on-time, the car gets digital locked until the payment is received.
  2. Smart contracts are like Ricardian contracts
    No. Ricardian contracts, popularized by Ian Grigg, are semantic representations that can track the liability of an actual agreement between parties.
    These can also be implemented on a blockchain, with or without a smart contract. Typically, multiple signatures are part of a Ricardian contract's execution.
  3. Smart contracts are legally enforceable
    Smart contracts are not law (yet), but they could represent pieces of a legal agreement. The legalities around smart contracts are a work in progress.
    A smart contract outcome could be used as an audit trail to prove that terms of legal agreement were followed or not.
  4. Smart contracts include Artificial Intelligence
    Smart contracts aren’t really that smart on their own.
    Smart contracts are really software code that runs on a blockchain, and they are triggered by some external data, that lets them modify some other data.
    So, they are closer to an event-driven construct, more than artificial intelligence.
  5. Smart contracts are blockchain applications
    Smart contracts are usually part of a decentralized (blockchain) application. There could be several contracts to a specific application.
    For example, if certain conditions in a smart contract are met, then the program is allowed to update a database.
  6. Smart contracts are easy to program.
    Yes and no. Writing a simple contract is fairly easy, especially if you are using a specific smart contract language (eg Ethereum’s Solidity), which lets you write complex processes in a few lines of code.
    But there are more advanced implementations of smart contracts that use "oracles". Oracles are data sources that send actionable information to smart contracts.
  7. Smart contracts are for developers only
    True today, but we will soon see more user-friendly entry points that will allow any business user to configure them via a graphical user interface, or perhaps a text-based language input.
    Ethereum's Mist browser is a step in that direction.
  8. Smart contracts are not safe.
    Not true. Even in the Ethereum implementation, smart contracts run as quasi-Turing complete programs, which means there is finality in their execution, and they don’t risk looping infinitely.
  9. Smart contracts have limited applications.
    Not true. Like HTML, the applications are limited by whoever writes them. Smart contracts are ideal for interacting with real-world assets, smart property, IoT, and financial services instruments.
    They apply to almost anything that changes its state over time, and could have a value attached to it.
So to finish with this basic introduction:

The lack of clear terminology in this field is an unfortunate reality. Those of us who work in the blockchain space should be mindful of how the term is being used in different communities, and be prepared to ask a series of annoying, though necessary, clarifying questions when asked about the nature and potential of “smart contracts”.
The different uses of the term illustrate a broader challenge in our industry. The interdisciplinary nature of blockchain technology, and “smart contracts” in particular, lead people to see the technology as primarily belonging to their own discipline, at the expense of the others.
Lawyers often look at smart contracts and see marginally improved legal agreements, without appreciating the fuller potential of blockchain-code to extend beyond law’s reach.
Developers, on the other hand, consider smart contracts and see the limitless possibilities of software, without appreciating the subtleties and commercial realities reflected in traditional legal agreements.
As with any interdisciplinary field, both must learn from the other.


sources:

https://en.wikipedia.org/wiki/Smart_contract
Dean Walsh
http://cryptorials.io/a-beginners-guide-to-smart-contracts/
William Mougayar
http://www.coindesk.com/smart-contract-myths-blockchain/
http://www.coindesk.com/making-sense-smart-contracts/

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.029
BTC 62581.77
ETH 2546.73
USDT 1.00
SBD 2.75