Smart contracts (SC) are sets of digital code created to facilitate the transfer of assets (including non-digital assets). They originate as a way to reduce, or completely eliminate, the need for intermediaries in trustless third-party transactions.
In its simplest form, smart contracts are no different from regular contracts; namely, an agreement between two or more parties. Smart contracts utilize bits of computer code that rely on logic to be executed, and the transactions only happen when the conditions on the agreement are met. The most rudimentary way of understanding them is through if-else statement logic, most commonly known as conditional programming. Let us showcase this through an example.
Take Kim, a tenant who wants to enter into a rental agreement with a landlord, Park. One option would be for Kim and Park to enter into a traditional agreement. Usually, traditional rental agreements have many intermediaries that aim to ensure validity and enforceability of the contract; banks, brokers, lawyers and others may be included in the process. This agreement, however, doesn’t guarantee that either party will fulfil their obligations. Kim could send an advance payment for the reservation of the flat and Park could then deny Kim access to it, or Kim could stay in the property while refusing to pay. A smart contract would be a trustless alternative, which executes a command (like sending Kim the monthly flat code) only if a certain predetermined condition is met (Kim sending the predetermined rate to the SC, locking the funds in the SC as an insurance protocol).
Source: GOB Platform [1]
Of course, this example is an oversimplification. Countless other inputs including insurance, contingencies, and others can be added to make the agreement more complex and take into account multiple scenarios.
Characteristics of smart contracts
Most smart contract characteristics are derived from the underlying blockchain technology:
- Secure: Cryptography is used to secure contracts and stop people from altering records. While the technology is highly secure in most instances, there have been several cases where SC have been hacked and the funds deposited withdrawn [2].
- Transparent: When running on public networks, anyone can see what the smart contract is and what it’s being used for.
- Free of third-parties: As we presented initially, smart contracts don’t need a middleman to be involved in the verification process.
- Near real-time execution: Although dependent on the underlying networks’ throughput and congestion, smart contracts usually take place almost simultaneously for all parties, across participating computers, once the necessary criteria are satisfied.
- Autonomous and decentralized: SC’s work automatically, so you’re not having to wait for someone to push a button. Additionally, once deployed, they can’t be changed or controlled by any centralized party (like banks, brokers, or even by the network).
- Accurate: Because smart contracts are written in code, they don’t rely on the grey areas of a language and what words mean. This can pose an inconvenience, especially when grey areas that require flexible solutions exist.
Caveats and limitations of smart contracts
Just as everything is not as it always seems, smart contracts are not always so smart. Their deterministic nature that can be regarded as a benefit, can also be a restriction to its inner workings. SC’s have several limitations that can slow down their adoption, and must be taken into account when developing them.
Built-in rules. Smart contracts are only as good as the rules, conditions, logic and scenarios built into them. This means that programming quality is crucial. A smart contract that includes only a handful of rules won’t be able to execute more comprehensive scenarios. The less it’s left to chance, the better the contract. Going back to our example, what if Park wanted to include a clause that allows him to check the flat before releasing the deposit back to Kim?
Since a smart contract is a computer program, each term and condition of the contract needs to be coded. There is a possibility of misinterpretation and omission by the coder, which may lead to loopholes in the contract.
The next two most important characteristics of SC’s include the data input and security.
Data is fed into blockchains and used for smart contract execution from external sources, specifically data feeds and APIs. These real-time data feeds for blockchains are called “oracles” – they’re essentially the middleware between the data and the contract. Oracles can be software- or hardware-based. Imagine an insurance smart contract that releases payment if certain areas are hit by winds greater than 100 mph. The SC would fetch external data (in this case from an anemometer) and pay depending on the input (mph). Because at times there are few (or even one) data sources, this burdens the decentralization aspect, causing a central point of failure in the SC.
Bugs and errors in the code – Even though it’s recommended for a smart contract to be a hybrid between computer code and actual physical contract (worded), bugs and errors in code could lead to disputes and procedural difficulties related to identifying errors and the parties responsible for those. In June 2016, for example, a hacker exploited a vulnerability in the code of the Decentralized Autonomous Organization (DAO), which is a piece of smart contract built on Ethereum, and made away with 50 million Ether [3].
Trustless? – Because physical assets are regulated by the laws in the jurisdiction they are in, this creates an intrinsic problem in the linkage between property of a digital asset that represents a physical (real) asset, and the real asset. This implies a dependency on a third-party, somewhat stripping SC’s from their characteristic of “total” decentralization and trustlessness [4].
Resources
[1] “House Rental DApp of GOB Platform.” Medium, GOB Platform, 28 Feb. 2019, medium.com/gobplatform/house-rental-dapp-of-gob-platform-4c104a1c530b.
[2] “3 Famous Smart Contract Hacks You Should Know.” Medium, Firmo Network, 29 Apr. 2018, medium.com/firmonetwork/3-famous-smart-contract-hacks-you-should-know-dffa6b934750.
[3] Siegel, David. “The DAO Attack: Understanding What Happened.” CoinDesk, 17 Dec. 2020, www.coindesk.com/understanding-dao-hack-journalists.
[4] Song, Jimmy. The Truth about Smart Contracts. Medium, 15 June 2018, jimmysong.medium.com/the-truth-about-smart-contracts-ae825271811f.
Sources
Zhang, Jim. What Are Smart Contracts and How Do They Work? Kaleido, 1 Oct. 2019, www.kaleido.io/blockchain-blog/what-are-smart-contracts-and-how-do-they-work.