Introduction

In the 1990s, Nick Szabo first proposed the concept of smart contracts. At that time, he defined smart contracts as tools that regulate and ensure the security of computer networks by combining protocols with user interfaces.

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

In the cryptocurrency world, smart contracts can be defined as applications or programs that run on a blockchain. Typically, they function as digital agreements that are enforced by following specific rules. These rules are predefined in computer code and replicated and executed by all network nodes.

Blockchain smart contracts support the creation of trustless protocols. This means that parties to a contract make a commitment via the blockchain without knowing or trusting each other. The parties determined that if the conditions were not met, the contract would not be executed. Additionally, using smart contracts eliminates the need for intermediaries, significantly reducing operating costs.

While smart contracts have been supported by the Bitcoin protocol for years, they were popularized by Ethereum creator and co-founder Vitalik Buterin. It’s worth noting that each blockchain implements smart contracts differently.

This article will focus on smart contracts that run in the Ethereum Virtual Machine (EVM), which is an important component of the Ethereum blockchain.


How do smart contracts work?

In simple terms, a smart contract is a deterministic program that performs a specific task when certain conditions are met. Therefore, smart contract systems usually follow "if...then..." conditional statements. Although the concept of "smart contracts" is well known, they are neither legal contracts nor smart. They are just a piece of code running in a blockchain distributed system.

In the Ethereum network, smart contracts are responsible for executing and managing blockchain operations when users (addresses) interact with each other. Addresses outside of smart contracts are called "external accounts (EOA)". Therefore, smart contracts are controlled by computer code, while external accounts (EOA) are controlled by users.

Ethereum smart contracts basically consist of contract code and two public keys. The first public key is provided by the creator of the contract, and the other public key is the contract itself, which is used as a unique digital identifier for each smart contract.

All smart contract deployments are performed through blockchain transactions and are only activated when an external account (EOA) or other smart contracts are called. However, smart contracts are generally triggered for the first time by an external account (EOA), that is, a user.


Key Features

Ethereum smart contracts have the following common features:

Distributed. Smart contracts are replicated and distributed across all nodes in the Ethereum network. This is very different from other centralized server-based solutions.

Determinism. Smart contracts only perform pre-designed actions when the requirements are met. And the results remain consistent regardless of who executes them.

Autonomy. Smart contracts are relative to "self-executing" programs, and they automatically complete various tasks. In most cases, untriggered smart contracts remain in a "dormant" state and do not perform any operations.

Immutability. Smart contracts cannot be changed after they are deployed. Smart contracts can only be “deleted” after a specific function is implemented. So, we might as well say that smart contracts provide tamper-proof code.

Customization. Smart contracts are coded in a variety of ways before deployment. Therefore, they can be used to create a wide variety of decentralized applications (DApps). This is closely related to the fact that Ethereum is a Turing-complete blockchain.

Trustlessness. Two or more parties can interact through smart contracts without knowing or trusting each other. In addition, blockchain technology will ensure that the data is accurate.

Transparency. Smart contracts are based on public blockchains, so the source code is not only tamper-proof but also open and transparent to everyone.


Can smart contracts be modified or deleted?

Once deployed, Ethereum smart contracts cannot have new functions added to them. However, as long as the contract creator reserves a "SELFDESTRUCT" function in the code, the function can then "delete" the smart contract and replace it with a new contract. If the function is not reserved in the code, the smart contract cannot be deleted.

It is worth noting that through so-called upgradeable smart contracts, developers can have more flexibility in the immutability of the contract. There are many different ways to create upgradeable smart contracts, each with different levels of complexity.

As a simple example, imagine a smart contract that is divided into multiple smaller contracts. Some parts are designed to be immutable, while other parts enable a "delete" function. That is, part of the code (smart contract) can be deleted and replaced, while other functions remain unchanged.


Benefits and Use Cases

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

As decentralized and self-executing programs, smart contracts can increase transparency and reduce operating costs. Depending on the specific implementation, smart contracts can also increase implementation efficiency and reduce cumbersome fees.

Smart contracts are particularly useful when it comes to transferring funds or transactions between two or more parties.

In other words, smart contracts can be tailored for a wide range of use cases, including the creation of tokenized assets, voting systems, cryptocurrency wallets, decentralized exchanges, games, and mobile apps. Smart contracts can also be deployed with other blockchain solutions, covering areas such as healthcare, charity, supply chain, governance, and decentralized finance (DeFi).


ERC-20

Tokens issued on the Ethereum blockchain follow the ERC-20 standard. This standard specifies the core functionality of all Ethereum tokens. Therefore, these digital assets are often referred to as "ERC-20 tokens" and account for a large proportion of existing cryptocurrencies.

Many blockchain companies and startups have deployed smart contracts to autonomously issue digital tokens on the Ethereum network. After the tokens are issued, most companies distribute their own ERC-20 tokens through an initial coin offering (ICO). In most cases, the use of smart contracts can effectively realize fund transactions and token distribution in a trustless manner.


Limitations

Smart contracts consist of manually written computer code. Codes can have flaws and vulnerabilities, which can bring many risks. Ideally, smart contracts should be written and deployed by experienced programmers, especially when sensitive information and large amounts of money are involved.

In addition, some people believe that centralized systems can provide most of the solutions and functions of smart contracts. The main difference is that smart contracts run on a distributed P2P network instead of a centralized server. In addition, smart contracts are based on the blockchain system, so they are often tamper-proof or difficult to change.

The immutability of smart contracts has obvious advantages, but in some cases it can backfire. For example, the decentralized autonomous organization "The DAO" was hacked in 2016 and millions of ether (ETH) disappeared due to defects in the smart contract code.

Since smart contracts are immutable, developers were unable to fix the code. This ultimately led to a hard fork, which resulted in the creation of a second Ethereum chain. In short, one chain (part of the current Ethereum blockchain) "reverted" to the way it was before the hack, returning the funds to the original owners. The other chain (now called "Ethereum Classic") decided not to intervene in the hack, insisting that events that occur in the blockchain should never be tampered with.

It is important to note that the issue was not caused by the Ethereum blockchain, but rather by the incorrect execution of smart contracts.

Another limitation of smart contracts is related to their unclear legal effects. Smart contracts are in a grey area in most countries and are not yet applicable to the current legal framework.

For example, many contracts require both parties to the transaction to be properly authenticated and over 18 years old. However, the anonymity of blockchain technology, coupled with the lack of an intermediary, will conflict with contractual requirements. A solution to this problem may emerge in the future. However, smart contracts run on a borderless distributed network, making legal enforcement very difficult.


Disadvantages

Some blockchain enthusiasts see smart contracts as autonomous solutions that will replace much of the existing business and bureaucratic systems. While this may be possible, it’s still a long way from becoming the norm.

Smart contracts are indeed an interesting technology. However, characteristics such as decentralization, determinism, transparency, and immutability sometimes reduce the appeal of smart contracts.

The essential disadvantage of smart contracts is that they cannot solve many real-world problems well. In fact, some institutions currently use traditional server solutions as a stopgap measure.

Compared to smart contracts, centralized servers are easier and cheaper to maintain, and often have significant advantages in speed and cross-network communication (interoperability).


Summarize

There is no doubt that smart contracts have had a profound impact on the cryptocurrency sector and have indeed brought significant changes to the blockchain sector. End users do not necessarily interact with smart contracts directly. But in the near future, the application of smart contracts will be more extensive, covering various fields such as financial services and supply chain management.

Together, smart contracts and blockchain are disrupting nearly every area of ​​society today. But only time will tell whether these groundbreaking technologies can overcome the barriers to mass adoption.