How Smart Contracts make blockchain work

11 January, 2019

Blockchain and cryptocurrency are two of the hottest topics in technology right now. We talk a lot about both here and because of their impact on online gambling. Something as seemingly simple as depositing bitcoins in order to play the video slot is only possible because of the existence of these two technologies.

What you might not know is that neither blockchain nor cryptocurrency could exist in their modern state without additional technologies that support them. One of those technologies is known as the smart contract. It is the smart contract that acts as the glue that binds blockchain and cryptocurrencies together. Without smart contracts, it would be much more difficult to maintain and control Bitcoin's distributed ledger, for example.

What they are and how they work

We normally think of contracts in terms of legal documents that bind two or more parties together in some sort of agreement. An employment contract is a good example. It establishes the agreement between employer and employee regarding their business relationship.

A typical contract states that the employer agrees to hire and employ the worker at a certain rate of pay along with additional compensation and benefits. It may stipulate the conditions under which that worker may be fired. The contract also stipulates what is expected of the employee. It details when employment begins, what the employee's duties are, and so forth.

A smart contract is similar in some ways but vastly different in others. It works as an agreement between two parties on a network to complete a specific task. Smart contracts have been likened to vending machine operations for purposes of illustration.

When you put coins into a vending machine and press a button, the machine dispenses the product you are purchasing. That's how smart contract works. One party to the contract initiates the action while the other party completes it.

A smart contract governing your bitcoin casino deposit would involve you and your digital wallet along with the recipient and its digital wallet. Your digital wallet initiates the transfer; the recipients digital wallet accepts the transfer and triggers another contract that credits your casino account.

Sounds pretty simple, right? It is. Now consider this: there can be millions of smart contracts executed each and every day involving just one cryptocurrency platform alone. When you consider that there are thousands of available cryptocurrencies now on the market, you are talking potentially hundreds of millions of smart contracts being executed on a daily basis.

The purpose behind Smart Contracts

As the first commercially viable cryptocurrency and blockchain platform, Bitcoin introduced the world to a whole host of new technologies including smart contracts. Given that so many smart contracts must be executed to keep Bitcoin going, one might wonder why Bitcoin developers chose this method. The answer lies in the word 'decentralization'.

Decentralizing financial transactions - which is to say, keeping banks and governments out of the loop - requires some way of processing those transactions independent of existing financial networks and institutions. Ideally, it would mean processing transactions automatically. That is what smart contracts do.

As to why smart contracts are necessary, think about what happens when you make a traditional payment through your bank. Let us say you want to pay your broadband bill using your bank-issued debit card.

You provide the debit card number to the broadband company as your form of payment. The broadband company then submits that number along with the amount of the transaction to your bank for processing. The bank removes the money from your account and sends it to the bank account of the broadband company. Finally, the receiving bank transfers the money into the broadband provider's account.

The transaction you just processed requires two intermediaries: your bank and the broadband company's bank. If you were to pay your bill using cryptocurrency, those two intermediaries would be taken out the equation. Yet there would still be the need for a mechanism to complete the transaction. Smart contracts are that mechanism.

Smart Contracts beyond cryptocurrency

The great thing about smart contracts is that they can be executed automatically. One need only program the specific parameters into the contract and then let it alone. Any other smart contracts that would be triggered by the execution of the original contract will also execute automatically, in a chain. What does this suggest? It suggests that it is theoretically possible to build completely decentralized applications that require very little human intervention to operate.

Completely decentralized apps would not be possible using the Bitcoin blockchain and ledger. Why? Because Bitcoin has been coded in such a way as to limit its use to actual bitcoins. But that's where Ethereum comes in. The Ethereum platform takes the basic principles of Bitcoin's blockchain and expands them well beyond cryptocurrency.

By the way, Ethereum is not a cryptocurrency. It is a blockchain platform. The alt coin associated with the platform is known as ether. That's why you sometimes read stories about companies developing applications from Ethereum that have nothing to do with cryptocurrency.

Having said all that, imagine working for a large company that relies heavily on a proprietary software package for managing day-to-day business. Also imagine that much of what the software does is handled automatically. Such software is possible with blockchain and smart contracts.

Controlling the price of fuel

To illustrate the point, imagine an energy company that converts petroleum into fuel for cars and trucks. That company owns a network of fueling stations around the country. They could use a decentralized app to set the daily price of fuel and automatically update pumps connected by a system-wide network.

The decentralized app would have two components: one to set the price of fuel and another to change the actual price at the pumps. The first component would work on smart contracts that take into account certain market changes. One contract might account for the wholesale price of fuel while another accounts for the price competitors are charging at their pumps. The second component would rely on a smart contract that is only triggered after the contracts of the first component are executed.

Through the use of multiple smart contracts linked in a chain, the company can automatically adjust the retail price of fuel 24 hours a day, seven days a week. No human intervention is required. Every price change is also recorded permanently in the blockchain, making historical referencing extremely easy.

Completely decentralized organizations

There are some within the blockchain community who believe it's possible to create completely decentralized organizations devoid of a hierarchical leadership using the same smart contracts that power platforms like Bitcoin and Ethereum.

They envision a day in which corporations are no longer controlled by C-suite executives who make the rules of the game. Rather, corporations would establish company rules that would be 'codified' in smart contracts and executed automatically across the company's computer network.

Would such an arrangement work in the real world? In theory, yes. In practice however, there is a lot more to running a company than establishing a set of rules triggered by market conditions. Corporations are run by people who have thoughts, goals, needs, and desires. Subjecting them to automation via smart contracts would not be easy.

The other question to ponder is whether it is practically feasible to create enough smart contracts to account for every possible variable of running a company. When you consider the number of decisions that have to be made daily, even among small businesses, it quickly becomes apparent that the volume of smart contracts required to run a major corporation would be enormous.

Smart Contracts are changing the world

It may very well be that the world will start seeing the emergence of completely decentralized organizations 25 or 30 years from now. In the meantime, we will all have to be content with the smart contracts that power cryptocurrencies and the limited number of decentralized applications now on the market. That's enough to deal with for now anyway.

The fact is that smart contracts are changing the world. They make it possible for you and me to deposit bitcoins at an online casino in order to play Mega Moolah. They make it possible for investors to put money into cryptocurrency platforms and exchanges. They make it possible for national governments, like the government in Chile for example, to accept public tax payments via cryptocurrency.

Bitcoin and its competitors would be nothing without smart contracts. It is the smart contract that executes cryptocurrency transactions without the need for central banks or government authorities. As such, smart contracts have been likened to oil that lubricates the system. Perhaps a better illustration would be the fuel that drives the cryptocurrency car.

Now you have a better understanding of smart contracts and their relationship to cryptocurrency transactions. Hopefully you also understand that the basic principles of smart contracts open the door to all sorts of things with a much bigger reach than just trading digital coins. Because of the way smart contracts work in relation to blockchain, the potential for doing all sorts of things by way of automating computer technology is almost unlimited. We have only just begun to test the potential of smart contracts and blockchain.