Smart Contracts


At this point, we’ve covered the essentials regarding blockchain and decentralised consensus. But now that we’ve moved away from a central authority, it’s time to think about what the other possibilities are with this new technology. The ability to use direct peer-to-peer transactions will revolutionise payment systems by removing the need for an intermediary, but this is only the beginning. You’ll find similar intermediaries in every industry because up until this point in human society, someone needed to be trusted to oversee changes to the ledger. Now that the whole process can operate over a decentralised network, we can instead replace those middlemen with something a lot more efficient; computer code!

Smart contracts were first theorised by computer scientist and cryptographer Nick Szabo way back in 1994, who realized that we could use code to embed contracts into hardware or software. When two people create a regular contract between each other, both are required to act in good faith to fulfil their side of the bargain. Any breach of contract can quickly become expensive (in terms of time & money) to resolve. By using computer code and a decentralised ledger, we can create smart contracts that handle the exchange automatically, and remove the need for trust (they are decentralised, so no one can modify them for their own personal gain). All we need to do is write code that accepts specific inputs from each user and validates them according to the terms of the contract. If there’s an issue, the contract will cancel and return the inputs to the users. If everything looks good, the contract will execute and send the outputs.

The most common example used to explain this concept is a vending machine. You provide two inputs (money and your item choice). The vending machine then checks the amount of money, and ensures your item of choice is in stock. Once it has validated those inputs, it accepts the money and sends the output (delivering your item). This is the same premise that smart contracts use, although they can get a lot more complex based on the requirements of the users. It’s not just limited to currency either; anything that can be stored as digital data (such as images or music) or even digitised versions of official documents (called digital assets, more on these in the next section) can be safely and automatically distributed between people using a smart contract. Smart contracts allow us to automate a huge number of tasks and services, which will allow us to do some pretty cool things using blockchain.