What's a smart contract?

A smart contract is a computer program that is stored and runs on a decentralized ‘trustless’ network, such as a blockchain. By trustless we mean that the validity of information in the network can be verified by anyone. Many people think smart contracts only apply to newer blockchain networks like Ethereum, but Bitcoin also uses smart contracts, albeit with limited functionality.

Ethereum was originally conceived in part as a way to generalize Bitcoin’s smart contract functionality. Thus, the Ethereum network is a 'Turing complete state machine,’ which is an academic way to say it is a general-purpose computer that is also decentralized. Such a network's smart contracts can conceivably “compute” anything a program on a normal computer can. This means that the network can, in theory at least, host a messaging app, a video game, or even an entire social media platform. However, in their current state, decentralized networks are severely limited in the types of applications they can support, with speed and cost being the main limiting factors. We go into this in more detail in our Blockchain Trilemma article. It’s also important to note that Ethereum was only the first of many networks to create a general-purpose decentralized computing machine.

Why would someone choose to deploy a smart contract on a decentralized network over a centralized, cloud computing network such as Amazon Web Services (AWS)? Cloud computing, after all, is much faster and cheaper than its decentralized counterparts. The answer is that centralized networks make important trade-offs for their speed and cost.

Since smart contracts exist on a decentralized trustless network, they provide a greater guarantee on the fair execution of programs. For example, you must trust your bank to faithfully execute your online bank transactions. Even if the bank is trustworthy, perhaps an employee in the bank is malicious, a hacker has penetrated the bank’s network, or the computer hardware itself is faulty. Not to mention you have almost no direct way to audit the bank’s transactions, let alone the software they are using. Smart contracts and the decentralized networks they live on greatly reduce the need for these trust assumptions.

For many use cases, the benefits of transparency, trustlessness, and guarantees on execution integrity are not needed. For example, a program that models weather, or an air traffic control monitoring program would likely gain very little benefit from smart contracts, and would incur heavy penalties in terms of speed and cost. However, for many use cases that involve money or property, the tradeoffs of speed and cost are likely worthwhile. For example, a digital trading card game, an asset exchange, or a program to send and receive cryptoassets.

How smart contracts work

Decentralized trustless networks such as Ethereum can be thought of as a shared computer, with smart contracts being the software programs that run on the shared computer. Developers write smart contracts in a programming language, then deploy them to the shared computer. When you deploy a smart contract to the "computer," what you're actually doing is registering a special address on the network. Anyone can interact with a deployed smart contract by sending that network’s native token to the contract address. In the case of the Ethereum network, you would use ETH. This triggers the code in the contract to be executed according to its logic. The code is executed automatically along the 'if this, then that' model just like any other programming language.

For example on the Ethereum network, a simple smart contract could be written such that when you send 1 ETH to it, your 1 ETH is divided up into 12 equal pieces, each of which is sent to a specified address at one-month intervals. This would effectively create something similar to a trust fund.

For use cases that exist entirely in the digital world, smart contracts allow people to bypass intermediaries altogether. For instance, in our above "trust fund" example, we've effectively eliminated the need for lawyers and managed escrow accounts. Instead, we simply send ETH to the contract and rest assured that it will be sent to the trust fund recipient exactly as the contract states and without any need for further input.

Smart contracts are being used in much more complicated ways to create Decentralized Applications (DApps) to do things such as allow the permissionless exchange of crypto assets, or even games with digital property the players can truly own.

Read more: What’s a DApp?

Was this helpful?

Related guides

Start from here →
What is Ethereum?

Understand Ethereum's key characteristics.

Read this article →
What is ETH used for?

Understand the function and utility of ETH.

Read this article →
Who created Ethereum?

Understand the origin and early history of the Ethereum protocol.

Read this article →
How was ETH initially distributed?

Learn about the 2014 crowdsale, the initial distribution of ether (ETH), and why it's important.

Read this article →
What are ERC-20 tokens?

Learn the basics of the Ethereum token standard, what ERC-20 tokens are used for, and how they work.

Read this article →
What's a DApp?

Understand the basics of Decentralized Applications (DApps) on decentralized networks; their features and their current limitations.

Read this article →
What is DeFi?

Learn what makes decentralized finance (DeFi) apps work and how they compare to traditional financial products.

Read this article →
What is Ethereum's monetary policy?

Learn about the issuance rate of ETH and how it's governed.

Read this article →
What is ETH gas and how do fees work in Ethereum?

Learn about the unit for measuring transaction fees in Ethereum, get details on the Ethereum fee market, and discover how to customize the fees you pay.

Read this article →
What is EIP 1559?

Understand how EIP 1559 overhauls the fee market in Ethereum and what it means for ETH's circulating supply.

Read this article →
How does governance work in Ethereum?

Why governance is needed, Ethereum governance in practice, the concept of credible neutrality, and more.

Read this article →
What is Ethereum 2.0?

Learn about Ethereum's attempt to solve the blockchain trilemma with a move to Proof of Stake, sharding, and more.

Read this article →
How to buy ETH

Learn how to buy ETH and hold it securely in a digital wallet you control.

Read this article →
How to create an Ethereum wallet

Creating an Ethereum wallet is as easy as installing software on your mobile device or laptop/desktop.

Read this article →
Start from here →
Start investing safely with the Bitcoin.com Wallet
Over wallets created so far

Everything you need to buy, sell, trade, and invest your Bitcoin and cryptocurrency securely

Bitcoin.com in your inbox

A weekly rundown of the news that matters, plus educational resources and updates on products & services that support economic freedom