How it works

How to Use Ethereum Smart Contracts

By September 21, 2017 No Comments

So, you’ve heard a lot about Bitcoins already. Your friends discuss them often; some trade in them too. There’s plenty of talk surrounding blockchain technology in the news as well!

But there’s another cryptocurrency that’s been getting a lot of attention lately and has replaced Litecoin as the second-largest crypto-currency after Bitcoin. It is Ether- the default value token of the Ethereum blockchain platform.

In fact, owing to its wider potential applications, Ethereum is quickly catching up to Bitcoin as well. Vitalik Buterin, the person who invented Ethereum, wanted it to be essentially a democratic and decentralised network, a kind of a World Computer, that would gradually replace the traditional client/server model. The idea is to hand over the control of data to its original owner and the complete creative rights of any digital work to its author. Anytime changes are made to the relevant files, documents or notes, all the nodes in the network make the corresponding adjustment in their records.

The idea is to hand over the control of data to its original owner and the complete creative rights of any digital work to its author. Anytime changes are made to the relevant files, documents or notes, all the nodes in the network make the corresponding adjustment in their records.

As evident with Bitcoin, Ethereum is also built using blockchain technology. The only difference is that while Bitcoin is purely digital currency, facilitating money transfer from one individual to the other, Ethereum functions like digital money and is highly programmable too.

In Ethereum, a money transfer can be initiated automatically, provided certain conditions are met. For example, when you buy a house from someone, multiple parties may get involved in the purchase process, like bankers, lawyers, agents etc., making the purchase process slow and expensive.

In Ethereum, the homeownership can be transferred to the buyer, and the corresponding funds released to the seller, automatically through a piece of code. Once both the parties have agreed, no third party is needed to execute that arrangement.

This process is a significant benefit of Ethereum platform – smart contracts.

What are Ethereum Smart Contracts

What are Etehreum smart contracts
Before learning how to use Ethereum smart contracts, let’s throw some light on the underlying definition of a smart contract and understand what Ethereum smart contracts are all about.

By definition, a smart contract is a computer program code that facilitates, executes and enforces the negotiation and performance of a certain contract (agreement) through blockchain technology. This entire process happens automatically and can substitute or complement legal contracts. The smart contract’s terms and conditions are recorded in computer language, in the form of a set of instructions.

Smart contracts are an integral part of the Ethereum network. Whenever someone needs some task to be done, he/she can make a smart contract with the concerned service provider/s. As mentioned above, it’s nothing but a series of instructions that are written out in a programming language.

Once the initial instructions are done with, another function may get executed, and it would continue this way until the contract ends. No one can skip a step and move to the next one. In other words, a step just won’t work until the previous one/s has/have been executed.

While in a traditional business arrangement, it’s a paper-based contract that outlines the terms between two parties, in an Ethereum smart contract not only are these terms outlined, they are automatically enforced too, all with the help of a cryptographic code.

Let’s take an example of a vending machine, and the steps you’d need to take to make it work for you, to understand this process better.

  • You deposit a certain sum of money into the vending machine
  • You press the corresponding button of the item you need
  • That item comes out of the machine for you to collect

Fairly simple, right?

All these steps are linked to the step before them and get triggered automatically once the previous step has been executed. You are only required to deal with a vending machine, and need not be concerned with anything else. There is no person or process involved between you and whatever you request from the machine.

Let’s take a look at the example of the vending machine once again to understand how this process would work on the Ethereum network:

  • You deposit money into the vending machine, and the act is recorded by every node in the Ethereum network. All such transactions get automatically updated.
  • You press the corresponding button of the item you need, and that act is updated in the Ethereum network and its ledger.
  • The requested item comes out of the machine for you to collect, and every node and ledger in the Ethereum network records that transaction too.

Every transaction that happens in the Ethereum network is registered and updated by all the nodes. Hence, everyone stays involved in the contract and is accountable for his/her actions.

So, in a way, you could only send 20 Ether to your friend on a particular date using an Ethereum smart contract. To do that, you’d create a smart contract, and it would execute that command (of transferring 20 Ethers) on your behalf, provided the conditions specified by you in the smart contract are met. All steps in this process would get updated and validated by the nodes in the Ethereum network. Smart contracts can help you exchange shares, property, money or anything valuable in a conflict-free and transparent manner.

Bitcoin initially supported smart contracts in a way that people could use Bitcoins to transfer value between one another. The nodes would only validate the transactions as long as certain conditions were met. However, Bitcoins were only limited to currency exchanges, while Ethereum network allowed the programmers to create their own customised smart contracts. How they do that? Let’s find out!

How are Smart Contracts Programmedthe future of ethereum

Smart contracts are created by computer programmers using certain smart contract development tools. These contracts are entirely digital and are written in programming languages like Solidity (commonly used for Ethereum smart contracts), Serpent, LLL (based on Lisp – Low-Level Lisp-like language), Java, Go, C++ and Python.

The code of the contract defines the terms and consequences of the agreement, just as is done in the standard legal documents, clearly stating the obligations of the parties, benefits and possible penalties. This code is then automatically executed on the Ethereum network by its distributed ledger system (involving nodes).

Nowadays the majority of the Ethereum smart contracts are created using a Turing-complete programming language called Solidity. Turing-complete implies that the language doesn’t just solve the computational problems, it also includes adequate support for various functions, like infinite loops.

Solidity is quite like JavaScript and uses .sol as its file extensions. While Serpent (a Python-like language with .se file extensions) was quite popular for creating Ethereum smart contracts until some time ago, these days almost everyone uses Solidity as it’s far more robust.

Please keep in mind that Ethereum’s libraries are under continuous development and things may sometimes go out of sync with the newer versions. Hence, always use a stable or the latest dev version.

After you’ve successfully compiled a Solidity contract using .sol (or online compilers), and have deployed it on the Ethereum network, you can summon it using Ethereum web3.js JavaScript API and create web applications that easily interact with the smart contract/s.

Those were the primary Ethereum tools you need for programming smart contracts.

It’s essential that developers make the program code as simple as possible while creating smart contracts to be implemented on the Ethereum blockchain. This is to avoid high Ether (also known as ‘gas’) costs for running those codes. Complex codes can consume more computer power and deter users from interacting with the application (holding the smart contract/s).

Examples of Etherum Smart Contracts

Let’s take you through some real-life examples where Ethereum smart contracts are already being used to meet business objectives.

Prediction Markets and Financial ServicesAugur is a decentralised prediction market created on the Ethereum platform, using smart contracts. It’s a prediction tool that allows users to make predictions based on events happening in the real time, and profit from them.

Real Estate – Ethereum-based smart contracts are already disrupting the real estate industry by reducing the friction involved in mortgage contracts, liens and payments. Rex MLS, for instance, is a revolutionary new global listing platform where you can freely list and search properties. It’s based on Ethereum and the concept of smart contracts, wherein you get full control over your data and are not bombarded by any ads.

Identity and Privacy – Ethereum smart contracts are streamlining business processes by replacing the conventional trust methods with smart contracts. Companies can automate processes like the release of records, renewals and destruction using smart contracts. For instance, Trust Stamp is an Ethereum-based identity verification tool which makes use of social media and any other publicly available data to verify people’s identities and allocating unique FICO type of trust scores to them. Uport is another useful platform that serves as a self-managed identity and key management system. It features an easy-to-use interface, open source libraries and Ethereum smart contracts.

Entertainment – Platforms like Peertracks and Ujo are already in the process of de-centralising the music industry. They use Ethereum and its smart contract technology to give an absolute creative control to the artists (on their works) and do away with the need for platforms like Spotify, Reverbnation and Soundcloud. Moving on to the gaming world, there’s a real-time strategy game called Beyond the Void which uses Ethereum smart contracts to enable players to take over planets and destroy opponents throughout the universe.

Insurance – Ethereum has already started playing a significant role in the way technology impacts the insurance industry. The Ethereum blockchain technology can fast track insurers’ experience by using smart policies and smart contracts to automate the concerned processes. For instance, Dynamis is a peer-to-peer insurance platform that employs blockchain technology and the Ethereum smart contracts to manage additional unemployment insurance. It taps into LinkedIn to verify people’s identities and current employment status.

Examples of Etherum Smart Contracts Applications

How-Smart-Contracts-Works

As highlighted and explained above, Ethereum smart contracts can automate all kinds of operations and processes, the most obvious being the actions and payments that are conditional upon payment. Their capabilities extend to various organisational and business activities. Let’s take you through some important examples of possible Ethereum smart contracts applications:

Trade Finance – Ethereum smart contracts can be instrumental in streamlining international transfers of goods and services through a quick initiation of a letter of credits and payments while facilitating higher liquidity of the financial assets. Even financing efficiencies for the institutions, suppliers and buyers can be improved using smart contracts.

Derivatives – Ethereum smart contracts can streamline the post-trade processes by doing away with the duplicate processes executed by every party for verification of trades. They can also initiate appropriate business events. Some other areas where they can be helpful in this regard is standardisation of the contract conditions, optimisation of post-trade processing (in over-the-counter derivatives) and real-time valuations of positions (for constant monitoring and error reduction).

Government Formation – Although many claims that the voting system is tough to rig, there are others that doubt it majorly. Ethereum smart contracts can put all such concerns to rest by offering a highly secure voting system. People’s votes can be obtained in Ethereum ledgers, making it very hard for anyone to access. Smart contracts can be a big help in improving the voter turnout, as people would be able to vote online with the click of a mouse button.

Mortgages – Ethereum smart contracts can help in automation of mortgage contracts by automatically connecting the involved parties and creating a less-error prone and frictionless transaction process. Such smart contracts can automatically release liens and process payments once the loan has been paid in full. Some other areas they can help in this regard include improvement of record visibility, facilitating payment verification & tracking, and reduction of costs and errors involved in manual processes.

Cancer Research – These contracts can even facilitate better sharing of cancer-related data and contribute to cancer research. An appropriate patient consent management process can be created wherein data sharing, and data contribution can happen smoothly, while thoroughly protecting the patient’s privacy.

There are many other possible applications of Ethereum smart contracts including in areas like clinical trials, auto insurance, supply chain, land title recording, financial data recording, securities, law and order enforcement, personal health records management and others.

The Future of Ethereum Smart Contracts

what is ethereum token

In a continually expanding digital world wherein people can connect anonymously from anywhere, trust is rapidly becoming a major issue. We frequently rely on middlemen and third parties for this reason. However, it is all expected to change pretty dramatically with the help of Ethereum smart contracts.

Smart contracts are what separate Ethereum from the other major blockchain technologies. And their possible applications suggest that they’re going to disrupt many existing industries in a big way. In fact, the creators of Ethereum platform envision it to become the basis for the next big shift in networking – Web 3.0.

However, though smart contracts will rapidly replace human workforce in the coming times, there will always be a need for regulatory oversight. Smart contract interpretations will require new regulatory skill sets altogether! Apart from the risk of any unforeseen security flaws or scaling issues, there are many solid reasons to be quite optimistic about the future of Ethereum smart contracts!

 

Do you have any other examples on how to use Ethereum Smart Contracts? Anything that you have tried before? Let us know in the comments below!

YOU MIGHT ALSO LIKE

Donald Trump and Bitcoin

Donald Trump and Bitcoin

| Bitcoin, News, Quick Read | No Comments

Donald Trump and Bitcoin seems to be a mystery to everyone. The White House is…

TREZOR Review The Most Reputable Hardware Wallet

TREZOR Review: The Most Reputable Hardware Wallet

| Platform Reviews, Wallets | No Comments

As the popularity and the value of cryptocurrencies soars to unprecedented levels, more and more…

Ledger Nano S Review: The Most Secure Hardware Wallet

Ledger Nano S Review: The Most Secure Hardware Wallet

| Platform Reviews, Wallets | No Comments

For those taking the leap into the world of cryptocurrency, it can be a strange…


Megan Frydel

Author Megan Frydel

Megan is a self-thought blockchain enthusiast. She enjoys combining finance with technology, from a less-techy perspective. BiteMyCoin is her most recent project underneath the umbrella of an international digital marketing agency ANCHOVY.

More posts by Megan Frydel

Leave a Reply

THE ULTIMATE GUIDE TO SUCCESSFULLY INVEST IN ALTCOINS & ICOs

Download this free eBook and learn:
1. How Cryptocurrency was invented
2. How to identify a legitiment ICO
3. What is the lifecyle of a crypto coin
GET YOUR FREE E-BOOK
close-link
NEW TO CYRPTOCURRENCY
Find out where to begin with our beginners guide.
SEE OUR BEGINNERS GUIDE