What are Smart Contracts and How Do They Work?

Start trading crypto

Robert has reported for a variety of international publications including the Associated Press, The Guardian, Vice, and Decrypt. Current areas of interest include the political economy of technology, cryptocurrencies, and privacy. Robert has a Bachelor of Science from UCL, and a Master's degree from the University of Oxford's Internet Institute.

Smart contracts are pieces of computer code that let blockchain applications talk to each other. They power the vast, $100+ billion industry of decentralized finance. But uses aren’t limited to just that. People are using smart contracts in industries such as shipping, charity, and telecommunications.

Smart contracts defined

Crypto smart contracts are bits of code that run on blockchains.

Understanding smart contracts and blockchains

A blockchain is a ledger of financial transactions. Blockchains don’t track regular money, like the US and Canadian dollar. Instead, they track new forms of digital money called cryptocurrencies.

Buy and Sell Bitcoin, Ethereum, and dozens more cryptocurrencies with Wealthsimple. Sign up and Trade here.

Blockchain ledgers are decentralized. They aren’t powered by companies, like Visa or Mastercard, and the coins aren’t issued by governments. Instead, they’re maintained by anonymous computers and users across the world.

Some blockchains, like the Bitcoin blockchain, run on technology called proof-of-work. Proof-of-work blockchains verify transactions by having computers race to solve complex mathematical problems. This race “mines” new coins into existence. Other blockchains, such as Tezos, run on a piece of technology called proof-of-stake. Proof-of-stake blockchains award new coins to those who have pledged the most coins.

The most popular blockchain is Bitcoin, which was launched in 2009. At Bitcoin’s peak in 2021, each coin was worth about $67,000, and the entire blockchain had a market capitalization of $1.27 trillion.

A limitation of the Bitcoin blockchain is that you can’t really do much aside from send, receive, or hold Bitcoin. In 2013, a programmer called Vitalik Buterin set to work on a blockchain that would support smart contracts. He called it Ethereum, and launched the network in July 2015 together with a group of entrepreneurs and programmers.

Ethereum’s smart contracts

Ethereum’s innovation was that it would support decentralized applications. People could write their decentralized code, then get the Ethereum blockchain to execute them. Ethereum was, in effect, the world’s first smart contract platform.

On Ethereum, you could also write a smart contract to create new cryptocurrencies. These are known as tokens. They’re programmable, and you can make them do whatever you want. One popular standard, the ERC-721, underpins NFT smart contracts, or non-fungible tokens. These are commonly used for crypto art.

Cryptocurrency developers use smart contracts to put in place complicated monetary policies. Some smart contracts destroy tokens after you spend them. Others increase the token’s total supply each month.

Smart contracts aren’t limited to creating tokens. Aave, one of the largest smart contract platforms, manages $18 billion. Its smart contracts let you take out huge cryptocurrency loans from other users. The whole thing works on code. A loan manager doesn’t have to approve each loan, and a government or a bank can’t cancel it.

Aave loans, like all smart contract transactions, rely on computer code rather than human trust. The protocol has proven resilient. Loans will only execute if certain conditions are met, bypassing the need for trust.

You might point out that regular computer code is already full of these “if…then” conditions. , meaning that smart contracts add layers of unnecessary complexity. In some cases that is true—not everything needs to be on a blockchain. But the benefit of a blockchain is you can’t alter these transactions.

These features make blockchains particularly useful for areas that need lots of trust. As an example, let’s examine the delivery of prime cuts of beef.

Certain beef, say Kobe beef, is very expensive and cuts are shipped around the world. There’s a lot of fraud with Kobe beef—steak advertised as Kobe beef might be anything but. It’s also expensive to pay for the certifications that verify Kobe beef as Kobe beef.

The Japanese farmer could add a QR code that links to a unique cryptocurrency token. Later, a shopper in a high-end French supermarket could pick up that beef from the shelf and scan the code. The shopper could verify that the specific cryptocurrency token relates to that piece of beef.

The power of the smart contract depends on the resilience of the entire blockchain. Blockchains need more than half of all miners to agree on a transaction for it to go through. To alter the database, one bad actor would need to overwhelm, and then control, over half of a blockchain’s miners. That’s near impossible with blockchains as large as Ethereum.

Critics point out that smart contracts are only one piece of the puzzle.While the smart contract might be secure, it’s still possible to, say, switch the label on a cut of beef. Such criticisms don’t apply to decentralized finance, the multi-billion dollar industry that revolves entirely around cryptocurrencies.

Origins of the smart contract

The concept of the smart contract predates Ethereum. Computer scientist Nick Szabo coined the term in the early 1990s. (Some people think that Szabo created Bitcoin. Szabo has denied these claims).

The Ethereum whitepaper claimed that Bitcoin was a weak implementation of the smart contract. Bitcoin applications that predate Ethereum, like Counterparty, attempted to bolt NFTs onto Bitcoin. These NFTs became valuable in the early 2020s after traders converted them to Ethereum. Taproot, a 2021 upgrade for Bitcoin, allows for limited applications of smart contracts.

After Ethereum popularized the smart contract, new blockchain platforms innovated on its creation. Blockchains like Cardano, EOS, and Tezos came first. Cardano is the most successful; it has a market capitalization of $36 billion as of February 2022. Ethereum is still top dog (after Bitcoin), with a market cap of $332 billion. In 2020 and 2021, a new class of smart contract-enabled blockchains took the market by storm. Top smart contract platforms include Solana, Polkadot, and Avalanche.

Blockchains that came out after Ethereum try and speed things up. Ethereum clunks along at 14 transactions per second, and transaction costs can cost up to $200. Newer blockchains are blazingly fast and often cheaper to use. However, they’re often not as decentralized as Ethereum.

After the blockchain bubble grew in the late 2010s, it seemed like companies wanted to put everything on the blockchain. The applications of smart contracts are near endless. In the section that follows, we’ll outline some of the more notable examples.

Digital identity

Smart contracts can power digital identity platforms. Marking something with a cryptocurrency token creates a reliable, decentralized reference. One interesting application of this is the charity sector. A company called AID:Tech uses smart contracts to ensure that money reaches those who need it most.

Decentralized exchanges

Decentralized exchanges allow you to trade cryptocurrencies without the need for centralized organizations. Popular examples include Uniswap, PancakeSwap, and SushiSwap. These protocols aim to replace centralized organizations like Binance and Coinbase. They use computer code to maintain huge pools of funds that traders can swap in and out of.

Decentralized stablecoins

Stablecoins are financial assets that maintain a peg to something else. Most commonly, the US dollar. The most popular stablecoins, USDC and Tether, are run by large companies. But lots of these companies have shady financials and investors fear bank runs. That’s created a demand for decentralized stablecoins that run on smart contracts. One popular decentralized stablecoin protocol, Maker, backs its stablecoin, DAI, with cryptocurrency loans.

Payment disputes

Companies devote a lot of resources to working out how much they have to pay for goods and services. Settling the bill, also known as “reconciliation,” is no easy task. Calculations can quickly become complicated, especially when they involve lots of companies. Some industries have toyed with using smart contracts to try and simplify things.

The music industry has long considered using smart contracts to collect royalties. A smart contract could mark each song with a token, then collect royalties whenever a song is played.

The telecommunications industry is considering something similar. When you place a phone call, telecommunications companies route your data across different providers. At the end of each month, they have to settle the bill at the end of each month. Companies like Clear want to streamline the process of reconciliation. How? By putting the entire system on the blockchain.

Frequently Asked Questions

A smart contract is a piece of code that powers blockchain applications. These applications, known as dApps(decentralized applications) run entirely on code and can operate without human intermediaries. Popular examples include decentralized lending protocols, which let you take out crypto loans without the need for a loans manager, or digital identity systems, which could one day replace your passport with a cryptocurrency token. The advantage of the smart contract, claim its proponents, is that it is trustless and that transactions don’t require any intervention. This cuts out middlemen, saving on costs and the potential for corruption.

To execute a smart contract, you’ll have to pay a “gas” fee. This fee goes to the network and is used to reward the participants (known as miners or validators) who process your transaction. This gas token is usually the native coin of the blockchain. For Ethereum, it’s ETH, for Solana, it’s SOL and for Avalanche, it’s AVAX. The only notable deviation to this is blockchains on the Cosmos ecosystem (called appchains), which operate independently from one another; there is no “official” coin on the Cosmos ecosystem, and a decentralized exchange might be powered by the native cryptocurrency issued by that exchange.

Smart contracts can be slow and expensive to use. Ethereum, the largest smart contract platform, processes transactions at speeds no greater than 14 transactions per second, and these transactions cost tens of dollars—and occasionally hundreds—when the network becomes congested.

Last Updated May 17, 2022

Buy & sell crypto instantly

Start trading
Spinning Wealthsimple coin

Buy & sell crypto instantly