Crypto Explained

What Is a Blockchain Smart Contract?

April 27, 2021


Smart contracts are blockchain-based programs that self-execute when certain conditions are met. They can power something as simple as an ERC20 token or as complicated as an entire decentralized finance (DeFi) application.

Smart contracts have been around in a conceptual sense since the 1990s, first proposed by computer scientist Nick Szabo, who remains a prominent figure in the blockchain and cryptocurrency space today. Szabo likened the idea of a smart contract to a vending machine.

Szabo acknowledged that a distributed ledger would be an optimal platform for executing smart contracts, as the nodes on the network could oversee operations.

How do smart contracts work?

On the most basic level, the smart contract works on an “if-this-then-that” logic. It will fulfill its conditions when a trigger action occurs, similar to putting a coin in a vending machine and receiving a can of soda in return.

Although the launch of Bitcoin in 2009 offered some basic execution logic, the Bitcoin blockchain was only capable of accounting transactions of bitcoins. It cannot handle anything more complex. It wasn’t until an enterprising young developer called Vitalik Buterin found Bitcoin and figured out that a scripting language would allow a blockchain to run more complex applications. And so blockchain smart contracts were born.

In 2015, the Ethereum genesis block marked the launch of the world’s first smart contract platform—a decentralized network confirming smart contracts composed in the general-purpose Solidity programming language executed by the Ethereum Virtual Machine.

Fast-forward six years, and Ethereum is still going strong. Moreover, it now has a slew of smart contract platform competitors, including EOS, Binance Smart Chain, Solana, Neo, and many more.

Characteristics of Smart Contracts

Virtually all smart contracts have the same characteristics regardless of which platform they run on.

Firstly, once they’re put into production, it’s impossible to change a smart contract. It may be possible for developers to leave certain parts of the coding open-ended, allowing new functionality to be added. However, there’s no way to do this under the radar. Every change is visible to the entire network and published transparently on the blockchain.

Similarly, nobody can manipulate the outcome of a smart contract, and there is no room to interpret the terms. The process is deterministic, and the same input will always produce the same output.

Finally, all smart contracts have a state shared across the network. For example, a smart contract may be programmed to disburse tokens when someone deposits ETH into it. The smart contract state shows its token balance, its ETH balance, whether or not it has disbursed tokens, and, if so, when and to which addresses. Every node on the network has a copy of this information for every smart contract running on the platform.

Opportunities and Challenges

When coded correctly, blockchain smart contracts are a powerful tool. They can introduce automation, bringing efficiencies and saving time. And there’s very little risk of losing data because everything is backed up by nodes on the network. If a node goes down, other nodes retain the data, which means that the risk is extremely low on matured blockchains like ETH.

However, perhaps the most powerful strength of smart contracts is also a key weakness. Programming languages like Solidity are general-purpose languages by design and can be used to program any outcome. However, this also means that smart contracts programmed in Solidity can have bugs that result in unanticipated outcomes. These have significant ramifications for any smart contract, but the implications can be serious when there are considerable funds involved.

The most famous example is The DAO hack, where someone spotted a bug in a crowdfunded smart contract and used it to drain funds. This resulted in a controversial hard fork of the Ethereum and Ethereum Classic blockchains as the core development team decided to roll back the history to restore funds. However, over recent years, in particular, with the rise of DeFi, smart contract vulnerabilities have become more commonplace.

Examples of Smart Contracts in Action

In Ethereum, even the most simple ERC20 token is a smart contract. The underlying code contains certain mandatory conditions, such as “approve” and “transfer,” which will enable the movement of tokens to another address upon the approval of the key holders.

More complex iterations of smart contracts are used all across the DeFi sector. For example, in a decentralized exchange like Uniswap. When someone stakes liquidity in Uniswap’s liquidity pools, a smart contract automatically returns liquidity pool tokens representing their stake.

Similarly, Uniswap’s underlying smart contracts will also assign a share of the transaction fees accrued by the same pool as a reward for staking liquidity. When the user deposits their liquidity tokens back into the Uniswap protocol, a smart contract returns their stake along with a share of transaction fees.

Smart contracts can also be used to handle other features of tokens. For instance, it’s increasingly common, particularly in DeFi, that token ownership confers governance rights. Smart contracts can ensure that when each ballot opens, the token holder has a right to participate.

The use cases listed here are merely the tip of the iceberg. Enterprise adoption and the continuing growth of segments such as DeFi and NFTs mean that there are plenty more use cases for smart contracts. Many of these have still yet to be explored.

Related Articles

How to Trade Perpetuals and Make the Most of EQO-D on EQONEX

October 18, 2021

Ian Fleetham

Ian Fleetham, Head of Trading at EQONEX, shows how to trade Perpetuals on the EQONEX Exchange. Use EQO-D, the first EQO airdrop, and cross-collateral to make the most from your trades.

Keep up with crypto through EQONEX!

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Kelvin Ting explains Polygon (MATIC)

October 13, 2021

Kelvin Ting

Head of Blockchain Strategy, Kelvin Ting, explains the Polygon network and why EQONEX decided to list the MATIC token.

What Are Decentralized Applications (dApps)?

October 8, 2021


Decentralized applications are the inevitable next evolution of the apps that we now use to manage our lives. But what are decentralized applications, and what makes them different from centralized apps?

What Is a 51% Attack, and How Much Would It Cost?

October 5, 2021


In blockchain parlance, a 51% attack is a worst-case scenario, referring to a situation where malicious actors take over a blockchain network. However, pulling off a 51% attack is difficult (and expensive).