Smart Contracts


A smart contract is a program that runs on a blockchain. You can think of this program or computer code as a set of rules, like a regular contract. A smart contract can be as simple as basic logic written in a few lines of code.

The most popular network for smart contracts is Ethereum. Smart contracts on the Ethereum network are a type of Ethereum account. Smart contracts consist of

  • code (the functions of the smart contract)
  • data (the state of the smart contract)

Smart contracts in Ethereum are code snippets that run on the Ethereum Virtual Machine (EVM). App developers upload these programs into EVM storage and participants can request execution of these programs with varying parameters. Anyone can request that a smart contract code be executed by making a transaction request. Smart contracts are the programs uploaded to and executed by the EVM on the Ethereum network.

The code and data reside at a specific address on the Ethereum blockchain. In other words, a smart contract lives on the Ethereum blockchain. Deploying a smart contract is not free, because it uses network storage.

Smart contracts cannot initiate a transaction. In other words, smart contracts are reactive not proactive. They can only transact in response to receiving a transaction. An incoming transaction triggers the code which can execute a range of different actions, including transferring tokens or creating a new account. As an account, smart contracts on Ethereum have an ETH balance and can send ETH.

Smart contracts are decentralized, which means they are not controlled by any user. Although they are accounts, smart contracts are not controlled externally. They are independent. Smart contracts are deployed to the network and run exactly as programmed. A smart contract cannot be changed once it is deployed on the network. This means that smart contracts must be designed carefully and tested thoroughly. Once a smart contract is deployed on the blockchain, it is the blockchain network that serves users who want to interact with the smart contract.

As part of a blockchain, smart contracts do not rely on a trusted third party. There is no central authority managing the smart contract. This means that smart contracts are guaranteed to execute as written.

A smart contract defines a transaction which is intended to automatically execute according to the code. This makes it a form of transaction protocol. It controls a set of actions according to the terms of the contract (agreement). Users interact with smart contracts by submitting transactions to the account. The smart contract then executes the defined function. Smart contracts are deterministic, which means they perform the same function when executed.

The physical vending machine is a useful analogy for a smart contract. You insert a payment, make a selection, and the vending machine automatically delivers the product. There is no sales person involved in the transaction. A smart contract is a script that, when called with certain parameters, performs some actions or computation if certain conditions are satisfied. This is like a soda machine that delivers a can of soda after money is entered and a selection is made. Similarly, a digital vending machine could assign ownership of a digital asset if the user sends ETH to a specific address.

The vision for Ethereum is based on smart contracts. From the introduction to the original Ethereum white paper, “What Ethereum intends to provide is a blockchain…that can be used to create “contracts” that can be used to encode arbitrary state transition functions…simply by writing up the logic in a few lines of code.”

As described in the Ethereum white paper, smart contracts are state transition functions. They transition the state of the distributed ledger to an updated state.

Smart contracts run on a blockchain (decentralized network) and not a centralized server.

Smart contracts are the back-end code for decentralized applications (dapps).

There are other smart contract blockchains than just Ethereum. Examples are Cosmos, Cardano, Solana, Tron, and EOS.

Additional Reading

Introduction to Smart Contracts on ethereum.org