What Is a Smart Contract? Types of Smart Contracts
Contracts have long served to automate processes, particularly when a specific set of rules should be followed when certain conditions are met. Smart contracts bring this concept to the blockchain, where the rules can be programmed as code.
But what exactly constitutes a smart contract? Are there different types of smart contracts, or is the term generic?
1What Is a Smart Contract?
The U.S. National Institute of Standards and Technology (NIST) defines a smart contract as a “collection of code and data [...] deployed to a blockchain by means of cryptographically signed transactions”.
Under this definition, code is a set of rules that determines what actions the smart contract can perform and under what circumstances. The data is the information the contract stores and uses, such as the token balance, ownership information, or any other data needed by the rules.
The fact that code is deployed to a blockchain network, as opposed to a server controlled by a single entity, distinguishes smart contracts from their traditional counterparts. The blockchain provides the environment in which the contract's rules can be executed and recorded, rather than having to rely on a centralized application provider.
2What Are the Main Types of Smart Contracts?
Despite various suggested taxonomies, there is no common list of types of smart contracts. One way to classify smart contracts is by the primary function they perform. It is not always clear-cut, as a contract may perform multiple functions.
Asset Management Smart Contracts
Asset management smart contracts are responsible for holding, transacting, and managing assets.
Token contracts are the most common type of asset management contracts. On Ethereum, ERC-20 is a standard for fungible tokens, while ERC-721 and ERC-1155 are commonly used for NFTs and other tokenized assets. These contracts keep track of token balances or ownership and define how those assets can be transferred.
Escrow contracts are another type of asset management contracts. They hold assets on behalf of participants and release them when specific conditions are met, such as the completion of an agreed milestone.
Financial Smart Contracts
Financial smart contracts facilitate financial operations such as trading, exchange, lending, borrowing, and liquidation.
A common example of where such a contract is used is on Uniswap, where smart contracts automate token swaps through automated market maker (AMM) pools. Meanwhile, protocols such as Aave and Compound have smart contracts that facilitate algorithmic lending of crypto assets. These contracts also handle collateralization, liquidation, interest rates, and other financial operations.
These applications can combine multiple contracts and existing protocols, with each component handling a different part of the financial system. This ability to connect on-chain components is known as composability.
Governance Smart Contracts
Governance smart contracts are used to perform voting and decision-making functions on a blockchain.
A DAO (decentralized autonomous organization), for instance, can use them to manage proposals, voting, quorum requirements, and approved actions.
The contract, however, does not decide which proposal should pass. Users still have to submit proposals and cast votes. The contract’s only role is to apply the predefined governance rules to determine whether the requirements have been met.
Account-Control Smart Contracts
Account-control smart contracts are responsible for defining how transactions can be authorized.
Traditional blockchain wallets only have one cryptographic key associated with them, allowing any owner to spend all of the tokens in the wallet. Smart contract wallets, on the other hand, can have more nuanced rules.
For example, a multisig wallet would require multiple signatories to approve a transaction before it can be submitted to the blockchain. Other rules can include spending limits, time-locked withdrawals, or social recovery. All of these give users and organizations more control over how their accounts are operated.
Infrastructure Smart Contracts
Infrastructure contracts provide data or services that smart contracts otherwise could not access on the blockchain. Their primary role is, hence, to provide reusable building blocks rather than serve as the main application users interact with.
One type of infrastructure contracts are oracles, which make external information available on-chain. A lending protocol, for instance, might use an oracle for asset prices. Meanwhile, an insurance application could use external weather data to determine whether a claim meets its conditions.
Other infrastructure contracts can also support cross-chain messaging, automated triggers, or on-chain registries.
3How Does a Smart Contract Work?
The rules in a smart contract are fixed in its code, but they do not carry out on their own.
The Smart Contract Is Deployed to a Blockchain
To be made available on the blockchain, a smart contract needs to be deployed to the network. The contract code is submitted as part of a deployment transaction, which is then executed by the blockchain nodes. The smart contract’s address is also determined during deployment.
From that point on, users and other applications will be able to interact with that address. The contract itself remains inactive until a transaction or another supported trigger calls one of its functions.
A Transaction Triggers the Smart Contract
When a user wants to interact with a smart contract, their wallet would have to create a transaction containing the details of the requested action. These details may include (but is not limited to) which contract function to call and what inputs to provide.
The user then confirms the transaction in the wallet, which uses their private key to create a digital signature for it. Only then would the signed transaction be broadcast to the blockchain network for processing.
Some smart contracts need additional information or inputs to operate. If the information is not available on the blockchain, this is where the transaction will have to request it from an oracle (a type of infrastructure smart contracts, remember?).
The Blockchain Executes the Smart Contract
When a valid transaction is submitted, the blockchain will be able to execute the smart contract instructions. This process consumes resources, which is why transactions often require a fee, also called gas. The more complex an operation is, the more gas it will likely require.
If the transaction satisfies the contract's conditions, the programmed action is carried out and the resulting changes are recorded on the blockchain. Tokens may move, ownership may change, a loan balance may be updated, or a vote may be recorded.
In case the conditions are not satisfied, none of the changes will take effect. This could be because an input is invalid or the user does not have sufficient funds. Even if the transaction fails, users will likely not receive a refund for the gas spent, as the blockchain already used these resources to process the transaction.
4Smart Contracts on Ethereum and Other Platforms
As we mentioned above, smart contracts need a blockchain environment to run, and different blockchains will give smart contracts different environments for doing so.
Ethereum and the EVM
Ethereum is the most prominent smart contract platform, which has been foundational to shaping how smart contract platforms are designed and used.
Ethereum provides a programmable environment called the Ethereum Virtual Machine (EVM), which executes smart contract code. Developers typically write smart contracts in Solidity or Vyper, which are compiled into bytecode that the EVM can process.
The EVM enables Ethereum to host a wide variety of applications, which has led to the emergence of an extensive Ethereum developer ecosystem. Many blockchains, both Ethereum-based and independent, have adopted the EVM as their execution environment.
Other Smart Contract Platforms
There are, naturally, other blockchains that natively support smart contracts.
Some, like Polygon, Arbitrum, or Optimism, are therefore compatible with Ethereum contracts and development tools (EVM-compatible). This allows developers to use or adapt Ethereum-based contracts and tooling with relatively few changes. .
Blockchains such as Solana, on the other hand, have a unique execution environment with different programming languages.
These differences can affect fees, transaction throughput, execution costs, programming languages, developer tooling, and ecosystem support. As a result, choosing a smart contract platform is not simply a matter of whether it supports smart contracts, but of whether and how its underlying design fits the applications developers want to build.
5Benefits of Smart Contracts
Smart contracts’ benefits largely come from what happens when those rules no longer need to be carried out manually.
Fewer Manual Steps
Smart contracts can take over parts of a process that would otherwise require someone to check conditions, approve an action, or move assets from one party to another. In a more complex workflow, several steps can even be linked together so that one completed action triggers the next.
This undoubtedly reduces administrative work and makes execution more consistent, particularly when the rules are straightforward enough to express in code.
A Shared Record of Activity
Because smart contracts run on a blockchain, all of their transactions are recorded on a decentralized, shared ledger. This characteristic can enhance trust, security, and transparency, as it makes tampering virtually impossible and provides a single source of reference for all participants.
Depending on the blockchain and the contract, users may even be able to analyze the contract’s source code to inspect its features and logic. This openness can reduce the possibility of errors and bad-faith activity, though it is ultimately up to the users to verify the code.
Composable Building Blocks
Smart contracts can also be designed to interact with other contracts. This composability allows developers to build more complex workflows by simply connecting existing on-chain components.
For example, a financial application can combine token contracts, a lending protocol, and an oracle rather than building every function from scratch.
6Risks and Limitations of Smart Contracts
Unfortunately, the benefits described above are not guaranteed, as they still depend on the accuracy and trustworthiness of the contract’s rules and data.
The Code Can Be Wrong
A smart contract only follows the rules written into its code. If those rules contain a bug, an unintended behavior can become part of the contract's execution.
The risk is particularly significant when a contract controls valuable assets, because blockchain transactions are generally difficult to reverse once confirmed. One infamous example of such an incident is the 2016 DAO hack, which resulted in the theft of approximately $60 million in ETH, as reported by Medium.
That is why it is essential to have smart contracts audited by third-party security firms. An audit is a security assessment of the contract’s code that looks for potential bugs and vulnerabilities. These audits, however, are not foolproof, as they can only review the code and assumptions made by the auditors. It is always possible that a vulnerability exists beyond the scope of an audit or that the auditors have overlooked an issue.
External Inputs Can Affect the Outcome
This risk is especially prominent in contracts that rely on external data or other smart contracts. For example, a lending contract that relies on an oracle to determine a token’s price will undoubtedly be affected if the oracle’s data is incorrect.
The same principle applies when a contract interacts with another contract. If the other contract has a vulnerability or behaves unexpectedly, it may impact the first contract as well. Therefore, the security of a smart contract depends not only on its own code but also on external dependencies and how carefully they are audited.
Fixing a Problem Can Introduce New Trust
Some contracts include administrative controls that allow designated parties to pause functions, change parameters, or upgrade the contract. These controls are what allows issues to be quickly resolved, particularly when it comes to fixing bugs or responding to new developments.
However, since the administrators may act in bad faith, it is essential to research what administrative capabilities a contract has, if any, and what limitations or restrictions apply to them.
Administrative controls can be implemented in many ways. Some contracts utilize a proxy architecture, which allows the contract to change its internal logic while keeping the same address. Meanwhile, others may have multisig access or other restrictions that limit the potential damage.
7A Final Word on Smart Contracts and Their Types
The purpose of this article was not to convince you to use particular smart contracts or platforms. Instead, we hope to have given you an overview and basic understanding of what a smart contract is and the different types of smart contracts that exist.
Now that you have learned more about the basics of smart contracts, perhaps you are interested in learning more about specific applications of smart contracts and how to evaluate them. Or maybe you would rather explore other applications of crypto?
If you would like to see more content like this, you can visit the Coinminutes website at https://coinminutes.com/
Frequently asked questions
Not without a trigger. Smart contracts can be triggered by incoming transactions, calls by other contracts, or external triggers, for example, from oracles or other automation services like Chainlink Automation or Gelato
Once triggered, the execution can happen automatically, but again, something has to initiate it first.
Most protocols will publish an audit trail, from which you can usually navigate to the specific audit reports (often Trail of Bits, OpenZeppelin, Certik et al).
What matters is who did the audit, when, and if the code hasn’t changed materially since the audit was completed. For instance, an audit from two years ago of a contract that has been upgraded is not particularly useful.
Not necessarily. While smart contracts executed on a blockchain will do what their code says, the question of legal binding relies on jurisdiction, the parties involved, and how the underlying agreement is structured.
No. Crypto is the domain where smart contracts are often deployed today, but it is by no means the only one.
Any system that needs to enforce any kind of rule or conditional logic about the world can make use of a smart contract. Today we see smart contracts used to help manage insurance payouts, track supply chains, enforce access control, and more.