Blockchains - Smart Contracts - Part 1

Index of all Chipkin blockchain articles : BLOCKCHAIN AND THE INTERNET OF THINGS Index

13-11-27-11_image.png

By: Peter Chipkin

Click to View Part 2 of 2

Article Contents

  • Smart Contracts are part of the Blockchain
  • What is a Smart Contract
  • A Simple Example – A lottery
  • How are Smart Contract Programmed?
  • What does a Contract Look Like
  • Contracts and Legal Contracts

Smart Contracts are part of the Blockchain

Four elements characterize Blockchain

Replicated ledger

History of all transactions — Append-only with immutable past — Distributed and replicated

Consensus

Decentralized protocol — Shared control tolerating disruption — Transactions validated

Cryptography

Integrity of ledger — Authenticity of transactions — Privacy of transactions — Identity of participants

Business logic

Logic embedded in the ledger — Executed together with transactions — From simple "coins" to self-enforcing "smart contracts"

What is a Smart Contract

A fancy name for a program or app that is embedded in the block chain.

Its useful to look at the differences between a regular computer app and a smart contract. A smart contract has visible source code and source code that cannot be changed after the fact so that once verified, you know exactly how it will operate. Your know how it will operate today, tomorrow and the next day because like all data in the block chain it is visible and immutable.

Most regular apps don't have this degree of transparency so its impossible to verify the app output with certainty.

Not all blockchains have been designed to allow source code and applications to be embedded in them. Bitcoin does not allow smart contracts. Ethereum does. It was designed for it. The designers of the blockchains make choices about what programming language(s) they provide to implement these smart contract apps.

13-11-48-09_image.png

In the context of blockchains and cryptocurrencies, smart contracts are:

  • pre-written logic (computer code)
  • stored and replicated on a distributed storage platform (eg a blockchain)
  • executed/run by a network of computers: (usually the same ones running the blockchain)
  • and can result in ledger updates (cryptocurrency payments, etc)

… In other words, they are little programs that execute "if this happens then do that", run and verified by many computers to ensure trustworthiness.

13-12-03-11_image.png





A Simple Example – A Lottery

Consider a lottery. You purchase a lotto ticket, you see the result, you check your ticket. You are probably not a winner. How do you know how many entries there were, how do you know if they drew the winner randomly and did not cheat. How do you know that they even declared a winner and that the winner was paid.

There is a lot of trust required.

That's why a blockchain lottery might suit you better. The source code is visible in the blockchain. So you can verify that it does indeed use a random method to pick the winner. Having performed the verification you can rely on it because the source code cannot be changed after the fact without braking the blockchains. You can see the number of tickets purchased because this data also resides in the blockchain. And finally, you can see the transactions where they paid the winner. All opportunities for cheating are defeated.


How are Smart Contract Programmed?

Ethereum developed a language called Solidity and a number of chains are using it.

NEO supports C# , VB.net, F#, Java and Python and are planning to add c, C++ and javascript.

The Smartchain provider provides a compiler to compile to binary objects that their chains understand.

Other names include "simplicity", "ivy", "bamboo"

It's the wild west out there and it will take some time for this to settle down and become stable.


What does a Contract Look Like

Sample Smart Contract. This application does nothing other than declare and initialize 3 variables.



The contract is compiled and 'Run'. In this case 'Run' means embedded in a block of the blockchain – this costs money – a transaction fee – which covers the cost of miner who added the block with this contract in it to the chain.

Here you can see it embedded in the block of binary data (shown as ascii in this view)


Here you see the transaction that resulted in the contract being embedded in the Ethereum chain. etherscan.io is a tool that allows you to see every single transaction in the chain. Thus, allowing anyone to verify the contract.




Here you see the payment for the contract from a wallet:



Contracts and Legal Contracts 

Because we are using the word 'contract' we must take care of terminology carefully. Contract has a specific legal meaning under law. Jurisdictions have rules of evidence for court cases.

Just because you block chain it doesn't mean a court will recognize the evidence of the security of the block chain .

defined variously as "autonomous machines" , "contracts between parties stored on a blockchain" or "any computation that takes place on a blockchain" . Many debates about the nature of smart contracts are really just contests between competing terminology.

Smart contract" another definition - the use of code to articulate, verify, and enforce an agreement between parties. A smart legal contract.

These smart legal contracts would most likely be a combination of smart contract code and more traditional legal language. For instance, imagine a supplier of goods enters into a smart legal contract with a retailer. The payment terms could be defined in code and executed automatically when delivery is made . But the retailer would likely insist the contract include an indemnity clause, whereby the supplier agrees to indemnify the retailer against claims flowing from a defective product. There would be no point representing this clause in code, since it is not something that can self-execute – it exists to be interpreted and enforced by a court in the case of litigation.


CLICK HERE TO GO TO THE NEXT ARTICLE

Contact Us

Contact us via phone (+1 866-383-1657) or leave a detailed message below for sales, support, or any other needs

*Required Field
*Required Field
I'd like to receive the newsletter. *Check email for confirmation.
*Required Field
8:00am - 12:00pm 12:00pm - 5:00pm
Message Sent Successfully