Expressed in computer code, Smart Contracts are how blockchains automatically execute an agreement between two parties without any intermediary. When the Smart Contract conditions are met, the supporting blockchain will execute the agreement for a fee, paid in the blockchain’s native cryptocurrency. The resulting transactions are cryptographically recorded on the blockchain and cannot be changed.
To flesh out the high-level description of what a Smart Contract is and does, we can look at how Smart Contracts work on the Ethereum blockchain, highlight examples of Smart Contract use cases and outline the specific benefits that Smart Contracts provide.
Unsupported content, you can view it in the full version of the site
VisitThough inspired by Bitcoin, which functions as a new form of money, Ethereum was designed with much greater ambition. It provides a foundational layer for any digital application that can be reduced to mathematics, programmable money being just one use case, with Ether serving as Ethereum’s native currency.
This capability is known as being ‘Turing Complete’ and led to Ethereum’s description as the world’s computer. To provide this foundational layer, Ethereum has its own scripting language called Solidity, which is how Smart Contracts are written. The instructions are processed in a run-time environment known as the Ethereum Virtual Machine - the EVM for short.
There are two main types of Ethereum accounts:
External users send/receive transactions using an Ethereum supported wallet like Meta Mask, and connect to Smart Contracts via a web browser and the user interface of an Ethereum supported application.
Contract accounts control Smart Contracts and use them to write state changes to the EVM. They connect with other Smart Contracts and External users.
Contract accounts now include a vast range of digital applications (dApps), building new types of permissionless economies on top of the Ethereum foundational layer. You’ll often hear these applications described as Protocols or Primitives. These names refer to the collective function of Smart Contracts and front-end applications like websites and mobile apps. We introduce examples below.
The EVM stores all Smart Contracts, and as Ethereum accounts interact with a Smart Contract the EVM will execute the requested change, and the most recent state is recorded in the Ethereum blockchain.
The Ethereum blockchain is a chain of blocks of data reflecting the state change of Accounts
that transfer value. As each block can only store a limited number of transactions, Ethereum charges a fee measured in GAS - denominated in Ether. Executing a transaction, therefore, requires GAS, which is paid for by the external user account that sends the transaction request to the Smart Contract.
GAS fees are earned by Miners who compete to add verified blocks of transactions to the Ethereum blockchain using an energy-intensive Consensus Mechanism called Proof of Work.
In June 2022 an upgrade to Ethereum described as the Merge will see it transfer to an alternative Consensus Mechanism called Proof of Stake, reducing its energy consumption by 99.5%.
It is also designed to reduce the fees required to execute Smart Contracts that have ballooned due to Ethereum’s popularity within DEFI and NFTs - the most popular use cases for Smart Contracts.
Ethereum’s Turing Complete design means that anyone can write a Smart Contract, there is no submission or vetting process. Smart Contracts can create their own rules and ownership structures. Given that Ethereum also supports token standards, it is a blank canvas for new permissionless methods of generating and exchanging value.
The inclusion of token standards was a masterstroke by Ethereum’s founder, Vitalik Buterin, because it allowed these new digital applications (dApps) the freedom to build their own mini-economies, with tokens for exchanging and creating value, as well seamlessly integrating with other applications through Smart Contracts - a concept called composability.
The most common Ethereum token standard is ERC-20. This set of guidelines allows developers to build applications with a unique token, which is interoperable with other products and services.
The ERC-20 standard specifically relates to fungible tokens within Ethereum and provides an API for tokens within Smart Contracts providing the following standard functions:
With a few extra lines of Smart Contract code, you can determine the supply, distribution and additional utility of a new fungible token. This ability opened the floodgate for alternative token systems to Ethereum and Bitcoin, commonly known as alternative coins (altcoins), and cryptocurrencies that are pegged to fiat currencies - Stablecoins - making them more appealing to traders and businesses.
There is also a standard for tokens that aren’t designed for exchange - non-fungible tokens (NFTs) - which Smart Contracts can apply to create in-game economies where users take ownership of what they create and earn within games, freely trading them outside of the game.
Play-to-earn is one of the fastest-growing areas of the Ethereum ecosystem, with Axie Infinity one of the most popular applications. It uses Ethereum’s Smart Contract capability to:
Decentralised Finance
Combining Smart Contract capability with a common standard for exchanging value enabled the emergence of a new phenomenon known as DEFI (Decentralised Finance). In simple terms, DEFI uses Smart Contracts to offer financial services to the External Account holders of Ethereum and other ERC-20 tokens.
Saving & Loans - Protocols like Compound use Smart Contracts to algorithmically offer interest on deposits and lend out funds against collateral. Compound alone has over $10bn in Ethereum based assets earning interest.
Decentralised Exchanges - Smart Contracts enable Automated Market Making - automatically providing liquid pools of tradable asset pairs without any central process or oversight. A DEX will incentivise users to provide liquidity (LPs) and then use algorithms to provide constant pricing and balanced liquidity pools.
DEX’s can also offer the same kind of complex derivatives trading offered by centralised exchanges but with much greater freedom, control and access to liquidity. dYdX and Uniswap are two of the most popular decentralised exchanges.
Yield Aggregation - Given the explosive growth in opportunities to generate a return from DEFI protocols, Smart Contract-based services will find the best strategies to optimise return, also known as Yield Farming.
Nick Sazbo, one of crypto’s OGs, summed up the function of Smart Contracts
“I call these new contracts “smart”, because they are far more functional than their inanimate paper-based ancestors. No use of artificial intelligence is implied. A smart contract is a set of promises, specified in digital form, including protocols within which the parties perform on these promises”
Describing traditional paper contracts as inanimate was a clever way of contrasting the restrictions with the analogue way of reaching an agreement, with the benefits of Smart Contracts.
Transparency & Trust
Smart Contracts increase trust as they are open and transparent and not lodged with an intermediary. Anyone can review the code and the logic to understand what will happen if an account interacts with it.
Reviewing Smart Contracts does, however, require technical know-how, and the creator of the Smart Contract won’t necessarily share their identity. Independent contract auditing is now a significant part of Smart Contract deployment. At the same time, there are also a growing number of off-the-shelf tools that can allow you to review Smart Contract function yourself.
Automation
Smart Contracts are digital and based entirely on logical arguments; they can be executed automatically, saving both time and cost. With the added benefit of Ethereum’s composability, you can quickly build out connected Smart Contract based services like lego blocks.
Immutable & Secure
One of the fears of entering into any traditional agreement is whether the terms will be honoured and how you can check. With Smart Contracts, anyone can check the outputs using blockchain browsers like Etherscan. The nature of blockchains means that transactions are immutable - they cannot be changed - providing a great deal of reassurance and security.
For the same reason, Smart Contract terns are secure and cannot be changed once committed to the EVM. But this is also a source of vulnerability, as we’ll now find out.
One of the most significant downsides to the decentralised Smart Contract model is that they will automatically execute whatever logic is coded into them. Given Smart Contract code is developed by humans who are prone to error, this frequently includes unintended vulnerabilities.
Code vulnerabilities are made worse by the common practice of copying Smart Contracts wholesale, including any broken logic.
DEFI became one of the biggest sources of crypto scams in 2021 with Chainalysis estimating that $2.3bn was stolen from DEFI protocols. The increasing complexity of Smart Contracts and the interoperability of so many DEFI protocols will likely cause these vulnerabilities to increase exponentially.
Ethereum was the first blockchain to introduce the concept of Smart Contracts, but there are now many rivals with their own scripting languages and chains built purposely to be EVM compatible.
The main reason for the rise of so-called Ethereum challengers isn’t any specific failure of Smart Contracts; rather the opposite, Ethereum has become a victim of its own success.
Smart Contracts are so efficient and have opened so many opportunities that the capacity of the Ethereum blockchain to commit the state changes to new blocks cannot keep up. This has seen the price of Smart Contract transactions (the amount of GAS required) rise sharply, pricing many users out of the market.
Rivals to Ethereum such as Solana, Polkadot, Cardano and Avalanche have developed their own Smart Contract languages and different Consensus Mechanisms with faster block confirmation times to accommodate significantly more transactions at a fraction of the cost. Unfortunately, their solutions generally offer scalability by compromising decentralisation or security.
Satisfying all those elements is what is known as the blockchain trilemma. Ethereum’s upcoming Merge and move to Proof of Stake is intended to address this, along with new approaches to processing transactions off-chain (using Rollups) then batching them to the main Ethereum chain to record the state change.
The use of Smart Contracts is almost certainly going to accelerate. They are fundamental to the promise of delivering what is described as web3.0, an internet experience where users control their data and identity and the value they create online.
Their creation will become simplified for an increasing range of tasks that involve digital agreement and value transfer. Still, given their vulnerabilities, we’re likely to see big improvements in Smart Contract auditing, new insurance products for protocol providers and users and more focus on blacklisting stolen funds.