Smart contracts have pretty much become an integral part of the “blockchain offering” alongside cryptocurrencies. However, we are at a weird conjuncture wherein we are either overestimating or underestimating the real capabilities of smart contracts. In this article, let’s gain a clear perspective of what they are and how they can revolutionize different industries and sectors as we move towards the future. So, how do smart contracts work? Let’s begin with the basics.
What are smart contracts?
How do you define contracts in the legal world?
Traditional contracts are human-readable, agreements between two parties. The agreements stated in the contract are a set of agreed-upon terms. Usually, one party needs to fulfill some tasks for the other party in exchange for a payment. A lawyer oversees this entire contract.
As you can imagine, this third-party acts as an obvious point-of-failure in the entire agreement. The only way that either of the parties will not get short-handed is if the overseeing party does a good job. What if one of the parties manages to corrupt the lawyer? In that case, it’s not really going to be a fair transaction now, will it?
Alright, so what’s the alternative? What if we somehow managed to make these contracts programmable?
That’s what smart contracts are. They are automated, self-executing agreements between two parties. These are computer protocols that will digitally facilitate, verify, or enforce the negotiation or performance of a contract.
The best part?
Smart contracts allow two parties to directly communicate with each other without having to go through an intermediary.
How do smart contracts work?
Nick Szabo, one of the greatest cryptographers of all time, came up with the term “smart contracts” back in the 90’s. Back then, he explained how smart contracts work by giving the example of a vending machine. How does a standard vending machine work?
- You choose the item that you want.
- You put in some cash inside the machine.
- The machine gives you the item.
So, in the functions above, there are two things that you should note about the whole interaction:
- You can directly interact with the machine without having to go through a third-party, like a shopkeeper.
- Each interaction is entirely dependent on the fulfillment of the previous one. For example, you can put your cash inside the vending machine until you choose the item you want.
These are the exact guiding principles of all smart contracts:
- The parties connected by the smart contract can directly interact with each other.
- Each step in a smart contract can only get fulfilled if the previous step gets successfully executed. There is a straightforward reason why this rule has been integrated. The fact of the matter is that smart contracts can sometimes deal with millions of dollars. This is the reason why it is crucial to account for each and every step that it takes.
A working example of smart contracts
Let’s take the smart rent system to understand how smart contracts work. You have the landlord and the Tennant. These two enter into a smart contract, wherein the tenant locks up the rent, with the condition that it will only release itself to the landlord if and only if the tenant has received the copy from the landlord. The landlord can send a virtual key to the tenant. The moment the contract detects this, it unlocks the funds to the landlord. Otherwise, the contract gives back the funds to the tenant.
As you may have noticed, smart contracts work with an IF-THEN-ELSE philosophy. IF the landlord passes the key, THEN release the funds over to them, ELSE payback the tenant.
Different smart contract use cases
Healthcare
The healthcare field is notorious for its silos. Smart contracts can help remove this barrier and give different departments access to cross-institutional data. Robomed Network uses tokenization to support smart contracts between medical service providers and patients. These contracts can oversee interactions between all patients and ensure that a certain level of service is continually maintained.
Government
Voting can improve tremendously with smart contract integration. Over the last decade, we have had so many rumors of ballot tampering. However, with smart contracts, it will be impossible to do since they are non-tamperable, by nature.
The Tennessee General Assembly took a significant step in this direction on March 8, 2018, when they officially recognized blockchain signatures and smart contracts as legally binding. Several other US states are looking to join Tennessee and expand the legality of blockchain technologies.
Supply Chain
Smart contracts can help take your supply chains to a whole new level. Track inventories with ease, finance supply chains, and reduce theft or fraud risk. Automate reports, invoices, checklists, and releases with smart contracts. For example, Name Bazaar is integrating its peer-to-peer marketplace with smart contract technology and allows users to swap internet domains.
Real estate
As we have already seen, smart contracts can allow different parties to buy, sell, or rent through smart contracts. Propy, a real estate company, has already used smart contracts to sell a $60,000 apartment in Ukraine.
How do smart contracts work – Execution Environment
For these smart contracts to work, they need the execution environment to operate in. This environment has three specific segments to it.
- Public-key cryptography is at the very heart of smart contract execution. This allows users to enter the contract and interact with the other party by signing off of transactions with their unique private keys and get cryptocurrencies sent to them in their public address.
- Secondly, it needs to be based on a decentralized protocol like Ethereum, IOTA, etc. The smart contracts’ core properties are decentralization, transparency, and immutability, which it inherits from the blockchain.
- The digital data source used by the smart contract news to be entirely reliable and use root SSL security certificates, HTTPS, and other secure-connection protocols
Benefits of Smart Contracts
- Transparency: Since smart contracts are built on top of the blockchain technology, they instantly get the transparency property. This is a vital component of contract-based negotiations since the terms have been pre-determined by the participants themselves.
- Accuracy of operations: Smart contracts also happen to be immutable. Once you enter some data into it, you can’t take it back. This is why the rules that govern the smart contract have to be followed very carefully and precisely.
- Security: Provided that the code is bug-free, the contract is governed by the same security level as afforded to the underlying blockchain protocol.
- Speed: Since the transaction doesn’t need to go through an intermediary, smart contracts are inherently fast.
- Efficiency: An increase in speed and accuracy equals increased efficiency.
- Trust: A secure and open ecosystem that encourages trust with the participants by bringing in a trustless platform.
- Guarantee: It is automated and self-executing, so it is not dependent on a system that needs humans to follow the rules.
Popular blockchain smart contracts platform
Now that we know what smart contracts, how they work, and their benefits, let’s now look at some popular blockchain chain smart contracts platform. We will be looking into:
- Ethereum
- IOTA
Popular blockchain smart contracts platform #1: Ethereum
Ethereum pretty much paved the way for smart contract platforms. Some properties of these smart contracts are:
- Coded using a Turing-complete programming language. As long as it has access to enough resources, it should be able to solve any problem (theoretically).
- Uses a mechanism called “gas” as a fee-meter to know when to terminate operations. Every single line of code in Ethereum costs a certain amount of “gas.” We will look into “gas” a little bit more in an upcoming section.
- Before the smart contract gets executed, a gas limit needs to be stated by the developer. The limit should account for enough gas to entirely execute the smart contract. If the limit isn’t enough, the contract will be reverted to its original state. The gas fees are paid in ETH (Ethereum’s native token).
What is Ethereum Gas?
Gas is the lifeblood of the Ethereum ecosystem. It’s the unit amount of computational effort you will need to execute a specific operation. Think of your smart contract as your car and Ethereum gas as petrol. If you don’t fill up enough petrol, you won’t be able to finish your journey. The same logic applies to smart contracts.
Remember, Ethereum is currently running on a proof-of-work (POW) protocol. You have specialized nodes called miners who use their ASICs to solve cryptographically hard puzzles within the ecosystem. The gas limit of a contract lets the miner know as to how much of their computational power will be used in executing it.
Ethereum’s Yellowpaper gives you a rough idea of how much gas a specific instruction costs.
What is Gas Limit?
Specifying the gas limit properly is extremely important for the smooth functioning of your contract. You can’t set your limit too high and you can’t set it too low, either.
Low Gas Limit
If your gas limit is too low, the miners will simply execute the contract until the gas limit runs out. Following that, the contract will revert to its original state, and you will still have to pay them for their services.
High Gas Limit
So, how about the other end of the spectrum? What if we set the gas limit too high? Theoretically speaking, the miners will use whatever gas they will need and then refund the rest back to you.
However, if you bloat up the gas limit, then you are going to make your contract extremely unattractive for the miners, as well. You must remember that every single block in the Ethereum blockchain is limited by a 6,700,000 gas-limit. All the components that a miner adds inside the block must be less than the block limit.
Image courtesy: Hackernoon
This is the reason why miners will not be open to the idea of inserting bloated smart contracts into their blocks.
Popular blockchain smart contracts platform #2: IOTA
We have covered IOTA smart contracts in detail before, which you can check out here. IOTA happens to be one of the most exciting projects in the space. Instead of a blockchain, IOTA uses a “tangle” as its underlying protocol.
IOTA smart contracts are layer-2, in nature, and act as “immutable state machines.” The IOTA smart contract has three different components – Owner, Economic and Social Incentives, and Quorums.
Owner
The smart contract owners are responsible for:
- Creating the smart contract code.
- Define the general parameters of the network.
- Submit the contract for validation.
- Select the quorum in charge of executing the contract.
- Defining how many validators are included inside the quorum.
Economic and Social Incentives
Even though IOTA transactions are feeless, the owners and validators can charge a certain fee to ensure that there is some substantial economic incentive to take care of the overall network upkeep.
- Owners can charge a fee to cover operational costs on their IOTA smart contracts.
- The owner and committee can predetermine their reward distribution.
- Social incentives can allow validator nodes to rake up good social points and earn more opportunities to be selected for quorums.
Quorum
The quorum has access to a unique smart contract address and contains locked IOTA tokens. IOTA uses a unique Boneh–Lynn–Shacham (BLS) signature scheme to ensure that the nodes in the quorum have uniform authority over the tokens.
Fintech smart contracts
Commodity Future Trading Commission
Fintech firms from around the world are opening up their eyes to the possibility of smart contract integrations. As per the Commodity Futures Trading Commission (CFTC), building Fintech smart contracts has the following benefits:
- Greatly decrease cost overhead via standardized code and execution.
- Transactions are kept secure in the immutable distributed ledger.
- Automation and self-execution reduces transaction time and unnecessary manual processes.
- Reduce counterparty and settlement risks with well-designed smart contracts.
- Automate digital asset and payment flow with smart contract execution.
- Tweak the code and add different contract information to create a whole new contract.
One of the most fascinating ways that fintech smart contracts and blockchain integration has changed the way international transactions work. The removal of intermediaries and the reduction of time have been revolutionary. They will have a considerable say in how fintech apps process international payments in the future – at the very least!
What are smart contracts disadvantages?
It will be unfair to conclude this article and not discuss some of the main issues plaguing the smart contract space:
- The legal status around smart contracts varies from country-to-country, which prevents them from achieving international interoperability.
- The learning curve for coding smart contracts can be extremely high. This is why the entry barriers are currently high, which acts as a bottleneck to mainstream adoption.
- Finally, even if some amazing developers are around, they are still humans at the end of the day. As such, they are prone to making mistakes, which leads to buggy code, and multi-million dollar hacks (Look up the DAO hack when you are done reading this guide).
What are smart contracts: Conclusion
Smart contracts will soon get integrated into every single aspect of our life. This is not an exaggeration when you consider the sheer number of use cases that are out there. This article’s purpose was to introduce you to smart contracts, its underlying philosophy, and functionalities. We hope that you gained immense value and knowledge from this article about the various nuances of smart contract functionalities.
Which reminds us, do you want to drastically cut down your learning curve when it comes to smart contract training?
If yes, then enroll for our world-famous blockchain education courses at Ivan on Tech Academy. The courses have been created by industry experts and our very own in-hour trainers. Check them out! They have been carefully curated and designed to give you the most value possible.