What on earth are smart contracts?
Tags: Ethereum, Smart Contracts, Blockchain Technology, Cryptocurrency, Dapps

Probably you already know what a (traditional) contract is, right? Let’s remember it, anyway. According to the Merriam-Webster dictionary, a contract is “a binding agreement between two or more persons or parties, especially one legally enforceable”. Well then, what is the first thing that comes to your mind when we say “smart contracts”?

Is the document on a tablet, maybe? Is it now a robot? An AI, behind a computer? It’s just… connected to the Internet? Not exactly. If you check other sources (like the ol’ reliable Wikipedia), they’ll say something like a smart contract is a “digital protocol” or “computer program” that executes its predetermined conditions automatically when these are fulfilled.

Nice, eh…? And what on earth that mean? Well, we can explain it this way: a smart contract isn’t something you can touch or even properly see. Mostly, you’ll only see the results, much like with the wires inside your TV. The difference is this time those results are completely digital because is a digital agreement based on a blockchain, written with computational code to enforce the previous conditions agreed by the parties. You can think of it as an automatic contract or warranty, that doesn’t need any paper, lawyer, notary, or middlemen in general.

So… how smart contracts work for your average guy?

The short answer is with digital apps or tools. If you don’t know how to write code (like developers or computer engineers), you won’t be in charge to create them, so, don’t worry. Leave that task to the experts. To use them, you’ll just need to pick a smart-contract-based app (usually decentralized apps) or platform and go with it on your device (mobile or desktop).

We can talk a bit about the internal workings of a smart contract, though. First of all, let’s check an image to show you how they look inside. Spoiler: it’s kind of boring. It’s just a bunch of code.

We also can check their data on a blockchain explorer (an accessible webpage), if it’s public, of course. The banks are developing their own applications with smart contracts, so, those aren’t public. But we can check, for example, an average contract on Ethereum.

We discover here an important thing about smart contracts. Besides code, they’re made of transactions and a monetary balance. However, this doesn’t mean the one and only use for them must be financial: the transactions can represent just information as well. As for the balance, the truth is, decentralized smart contracts require some fees to work (usually in form of cryptocurrencies), destined to the miners or validators of the blockchain.

The process is like…

Inside Ethereum, for example, a contract is just another kind of address (wallet/account), with balance and transactions. But is a kind of collective address, designed to work as a bridge between two or more parties, with preset conditions. Therefore, this address isn’t controlled just by one user, but by its own previously agreed terms, enforced by the entire Ethereum network.

The trigger for this address to do something (like automatically transact money) is an event expected by the parties. It could be a sale, a payment date, a record of something, a new product online, a price change, a poll, or even the sports results.

The contract reaches for the information provided about it by the parties involved or by an “oracle” (a software that consults external sources), and acts in consequence, following its preset conditions.

To sum it up, this is the process:

1. The parties negotiate the terms of the contract (or the company/developer make them public for everyone who wants to join).

2. The developer builds the protocol inside a selected blockchain ( Ethereum, EOS, Tron, Cardano, RSK, etc.), using the agreed terms.

3. The contract and its terms are represented inside an address of such blockchain.

4. The event happens.

5. The contract makes the transactions according to the result of said event.

Alice and Bob used smart contracts

Of course, we need a classic example with Alice and Bob. Let’s say Alice is going to bet $500 with Bob about the Bitcoin price for the next weekend. Bob thinks it will be up to X dollars, while Alice thinks it will be down X dollars.

So, they decide to build a smart contract (appealing to a developer or a platform-as-a-service) and set their conditions. The funds ($500) will be deposited in cryptocurrency to the contract, and if the price of Bitcoin is going up X for the next weekend, the contract will automatically transact the funds to Bob. If the price of Bitcoin is going down X, the funds will go to Alice’s address. And that’s it.

Now, another situation, this time involving some Internet of Things (IoT). Alice wants to rent her house to Bob, and she has the advantage of an installed smart lock, controlled digitally to open and close the door. So, they build a smart contract and set these terms: Bob will pay X dollars in crypto monthly.

If he fails to do so for two months, the contract will order the smart lock to keep the door (and the access to the house) closed. This way, Alice assures to duly receive the agreed figure, and Bob doesn’t need to gather any more documents or requisites for Alice.

And well, it’s a type of contract, after all. The imagination is the limit.

Some popular uses for smart contracts

There are already hundreds of smart-contract-based apps, with a lot of categories and functions. Exchanges, gambling, games, investment, real estate, healthcare, marketplaces, polls… they all work with smart contracts.

Maybe some of these Dapps (that aren’t per se smart contracts, but work with them), can ring a bell to you. CryptoKitties (collectibles), Uniswap (exchange), Aragon (governance), District0x (marketplaces and communities), Augur (prediction market), Synthetix (for synthetic assets), Axie Infinity (games), Grid+ (energy) and Actifit (health) are only examples. According to The State of the Dapps, there are over 2,500 of them.

And you know what else works with these contracts? The whole Decentralized Finance (DeFi) ecosystem, a boom these days. We can find there a lot of investment tools (for yield farming, mostly), loans, insurance, savings, and more. Platforms like Yearn Finance, Compound, UMA, Maker, Curve, and Pickle Finance belong to this category.

Beyond this, banks and companies like BBVA, Bankia, Sabadell, CaixaBank, IBM, Microsoft, Google, Ernst & Young, S7 Airlines, BitGive, Money on Chain, and OneSmart City are either testing smart contracts to improve their services or using them already in different applications. So, as you can see, we’re already full of these contracts.