Introduction

Nick Szabo first described smart contracts in the 1990s. At the time, he defined a smart contract as a tool that formalizes and secures computer networks by combining protocols and user interfaces.

Szabo discussed the potential use of smart contracts in various areas involving contractual agreements, such as credit systems, payment processing and content rights management.

In the world of cryptocurrencies, we can define a smart contract as an application or program that runs on a blockchain. In general, they operate as a digital agreement that is enforced by a specific set of rules. These rules are predefined by computer code, which is replicated and executed by all nodes in the network.

Blockchain smart contracts make it possible to create trustless protocols. This means that two parties can make commitments via the blockchain, without having to know or trust each other. They can be sure that if the conditions are not met, the contract will not be performed. Additionally, the use of smart contracts can eliminate the need for intermediaries, significantly reducing operational costs.

Although the Bitcoin protocol has supported smart contracts for many years, they were made popular by Ethereum creator and co-founder Vitalik Buterin. It should be noted, however, that each blockchain may present a different method of implementing smart contracts.

This article focuses on smart contracts that run on the Ethereum Virtual Machine (EVM), which is an essential part of the Ethereum blockchain.


So how do they work?

In simple terms, a smart contract works like a deterministic program. It executes a particular task when and if certain conditions are met. Therefore, a smart contract system often follows "if...then..." functions. But despite the terminology, smart contracts have no legal value, and are not intelligent. It is simply code running on a distributed system (a blockchain).

On the Ethereum network, smart contracts are responsible for executing and managing blockchain operations that take place when users (addresses) interact with each other. Any address that is not a smart contract is called an externally owned account (EOA). Thus, smart contracts are controlled by computer code, and EOAs are controlled by users.

Basically, Ethereum smart contracts consist of a contract code and two public keys. The first public key is the one provided by the contract creator. The other key represents the contract itself, acting as a digital identifier unique to each smart contract.

The deployment of a smart contract is carried out through a blockchain transaction. It can only be activated when called by an EOA (or by other smart contracts). However, the first trigger is always caused by an EOA (user).


main Features

An Ethereum smart contract often has the following characteristics:

Distributed. Smart contracts are replicated and distributed across all nodes of the Ethereum network. This is one of the main differences with other solutions that rely on centralized servers.

Determinist. Smart contracts only perform the actions they were designed to do, provided the requirements are met. Moreover, the result will always be the same no matter who performs them.

Autonomous. Smart contracts can automate all kinds of tasks, functioning like a self-executing program. In most cases, however, if a smart contract is not triggered, it will remain “dormant” and take no action.

Immutable. Smart contracts cannot be modified after deployment. They can only be “deleted” if a particular function has been implemented previously. So, we can say that smart contracts can provide tamper-proof code.

Customizable. Before their deployment, smart contracts can be coded in different ways. They can therefore be used to create many types of decentralized applications (DApps). This is because Ethereum is a Turing-complete blockchain.

Without trust. Two or more parties can interact via smart contracts without knowing or trusting each other. Additionally, blockchain technology ensures data accuracy.

Transparency. As smart contracts are based on a public blockchain, their source code is not only immutable, but also visible to everyone.


Can I modify or delete a smart contract?

It is impossible to add new functions to an Ethereum smart contract after its deployment. However, if its creator includes a function called SELFDESTRUCT in the code, he is able to “delete” the smart contract in the future, and replace it with a new one. On the other hand, if the function is not included in the code beforehand, it is impossible to delete it.

Remarkably, scalable smart contracts allow developers to have more flexibility on the immutability of contracts. There are many ways to create scalable smart contracts, with varying degrees of complexity.

In a simplified example, imagine that a smart contract is divided into several small contracts. Some of them are designed to be immutable, while others have the "Delete" function enabled. This means that part of the code (smart contracts) can be removed and replaced, while other functionality remains intact.


Benefits and use cases

As programmable code, smart contracts are highly customizable and can be designed in different ways, providing many types of services and solutions.

As decentralized, self-executing programs, smart contracts can provide increased transparency and reduce operational costs. Depending on their implementation, they can also increase efficiency and reduce administrative expenses.

Smart contracts are particularly useful in situations involving the transfer or exchange of funds between two or more parties.

In other words, smart contracts can be designed for a wide variety of use cases. Examples include the creation of tokenized assets, voting systems, cryptocurrency wallets, decentralized exchanges, games and mobile applications. They can also be deployed with other blockchain solutions that address healthcare, charity, supply chain, governance, and decentralized finance (DeFi).


ERC-20

Tokens issued on the Ethereum blockchain follow a standard known as ERC-20. The standard describes the basic functions of all Ethereum-based tokens. Therefore, these digital assets are often called ERC-20 tokens and represent a large portion of existing cryptocurrencies.

Many blockchain companies and startups have deployed smart contracts to issue their digital tokens on the Ethereum network. After issuance, the majority of these companies distributed their ERC-20 tokens through initial coin offerings (ICOs). In most cases, the use of smart contracts has made it possible to exchange funds and distribute tokens reliably and efficiently.


Limits

Smart contracts are made up of computer code written by humans. This presents many risks, as the code is subject to vulnerabilities and bugs. Ideally, they should be written and deployed by experienced programmers, especially when they involve sensitive information or large sums of money.

Furthermore, some argue that centralized systems can provide most of the solutions and functionality offered by smart contracts. The main difference is that smart contracts run on a distributed P2P network, rather than a centralized server. And because they are based on a blockchain system, they tend to be immutable or very difficult to change.

Being steadfast can be great in some situations, but very bad in others. For example, when a decentralized autonomous organization (DAO) called “DAO” was hacked in 2016, millions of ether (ETH) were stolen due to flaws in their smart contracts code.

Since their smart contract was immutable, the developers were unable to fix the code. This ultimately led to a hard fork, giving rise to a second Ethereum chain. Simply put, a chain “undoes” the hack and returns the funds to the rightful owners (this is part of the current Ethereum blockchain). The other chain decided not to interfere with the hack, stating that things that happen on a blockchain should never be changed (this chain is now called Ethereum Classic).

It is important to note that the problem does not come from the Ethereum blockchain. Instead, it was caused by poor smart contract implementation.

Another limitation of smart contracts is linked to their uncertain legal status. Not only because it is a gray area in most countries, but also because smart contracts are not suitable for the current legal framework.

For example, many contracts require both parties to be properly identified and over 18 years old. The pseudonymity provided by blockchain technology, coupled with the lack of intermediaries, may threaten these requirements. Although there are potential solutions to this problem, the legal enforceability of smart contracts is a real challenge, especially when dealing with distributed networks without borders.


Critiques

Some blockchain enthusiasts see smart contracts as a solution that will soon replace and automate much of our business and administrative systems. While it's possible, it's probably far from becoming the norm.

Smart contracts are certainly an interesting technology. But the fact that they are distributed, deterministic, transparent and somewhat immutable can make them less attractive in certain situations.

The criticism is essentially based on the fact that smart contracts do not constitute a suitable solution to many real-world problems. In fact, some organizations benefit from using traditional server-based solutions.

Compared to smart contracts, centralized servers are easier and cheaper to maintain, and tend to have increased efficiency in terms of speed and cross-network communication (interoperability).


To conclude

There is no doubt that smart contracts have had a significant impact in the world of cryptocurrencies, and they have certainly revolutionized the blockchain space. Although end users do not directly interact with smart contracts, they are likely to power a wide range of applications in the future, ranging from financial services to supply chain management.

Together, smart contracts and blockchain have the potential to disrupt almost every area of ​​our society. But only time will tell whether these revolutionary technologies will overcome the many obstacles to widespread adoption.