What is a smart contract?

Источник: Infura

What is a smart contract?

Source: Infura

Smart contracts are executing code that run without an intermediary, and the building block behind DeFi, stablecoins, and NFTs. Learn how they work.

•Updated: September 30, 2026

What is a smart contract?

Smart contracts are executing code that run without an intermediary, and the building block behind DeFi, stablecoins, and NFTs. Learn how they work.

  • MetaMask
  • How smart contracts work
  • A brief history of smart contracts
  • Where do smart contracts run?
  • Who writes smart contracts and uses them?
  • Token standards
  • What do smart contracts power?
  • Why do smart contracts exist?
  • Token approvals and safety
  • Smart contract risks

A smart contract is a self-executing code stored on a blockchain network that automatically carries out an agreement when its conditions are met, without needing an intermediary. Smart contracts power apps, DeFi, NFTs, and DAOs by enforcing rules transparently and reliably. Smart contracts aren't specific to any one network; Ethereum and other EVM-compatible blockchains, Solana, Cardano, Polkadot, and Sui all run smart contracts, each using its own programming language and execution model. Because a smart contract lives onchain, it runs without an intermediary, its rules are visible to anyone who wants to check them, and once deployed it generally can’t be altered. Smart contracts are the building blocks behind most blockchain apps, including DeFi protocols, stablecoins, NFTs, and DAOs.

Disclaimer: This guide is for educational purposes only. It is not financial advice, not a solicitation, and not for UK audiences. Interacting with smart contracts is risky and not suitable for all users.

How smart contracts work

A developer writes a contract and deploys it to a blockchain once. From that point on, anyone can interact with it, and it executes its logic whenever its conditions are triggered—for example, releasing tokens when a payment is received, or letting a user withdraw funds after a certain block height. Two properties define smart contracts across every network that supports them: execution is automatic and needs no middleman, and the code is immutable by default, so a bug is permanent unless the contract was specifically designed to be upgradeable.

Running a smart contract also costs something. Every network charges a network fee to process the computation and storage a contract uses—called “gas” on Ethereum and most EVM chains, and given different names and fee models elsewhere (Solana’s per-transaction fees, Cardano’s per-transaction fees plus script execution units, Polkadot’s weight-based fees). The mechanics differ, but the principle is the same: executing code on blockhains consumes network resources, and someone has to pay for it.

A brief history of smart contracts

The idea behind smart contracts predates any blockchain. Computer scientist and legal scholar Nick Szabo coined the term “smart contract” in 1994 and expanded on it in a 1996 essay, describing a computerized transaction protocol that executes the terms of an agreement, comparing the concept to a vending machine that reliably delivers a good once it receives payment, with no need to trust the other party (Szabo’s original writing, as referenced in histories of the concept). At the time, no platform existed that could run this kind of code in a trust-minimized, tamper-resistant way, so the idea stayed largely theoretical for two decades.

Bitcoin, launched in 2009, introduced a blockchain but only a limited scripting language (Bitcoin Script), which is intentionally not Turing-complete—it can enforce spending conditions like multisignature requirements and timelocks, but it can’t run arbitrary, general-purpose programs. Bitcoin Script guards how existing funds can be spent; it can’t express open-ended logic about what happens next, so Bitcoin is not considered a general-purpose smart contract platform.

Ethereum, which launched on July 30, 2015, was the first major blockchain built specifically to run general purpose smart contracts, via the Ethereum Virtual Machine (EVM), a shared runtime that every Ethereum node executes identically (ethereum.org, History of Ethereum). That made Ethereum programmable in a way earlier blockchains weren’t, and it’s why most smart contract terminology—gas (aka network fees), contract accounts, Solidity—originates there. In the years since, other networks built their own smart contract environments using different languages and execution models, including Solana (2020), Cardano’s Plutus scripts (2021), Polkadot’s ink! contracts, and Sui’s Move-based objects (2023), extending the concept well beyond a single network.

Where do smart contracts run?

The runtime and language a smart contract uses depends entirely on the network it’s deployed to. Some networks track state as account balances that contracts read and write (Ethereum’s account model); others track state as discrete, spendable outputs (Cardano’s eUTXO model, an extension of Bitcoin’s UTXO model) or as individually owned objects (Sui’s object-centric model). These differences affect how contracts are written and how they can be composed, but not the basic guarantee: code that runs automatically and, once deployed, is difficult or impossible to change.

Network

Language

Execution model

Notable ecosystem use

Ethereum and EVM networks

Solidity ; Vyper ; Compiled to EVM bytecode

Account-based; one contract call executes at a time per chain

DeFi ; Stablecoins ; ERC-20 and ERC-721 tokens

Rust, commonly with the Anchor framework

Sealevel: runs transactions in parallel when they don’t touch the same data

High-throughput DeFi ; NFT marketplaces

Plutus (Haskell-based)

Extended UTXO (eUTXO): transaction outcomes can be verified before submission

DeFi ; Native token issuance

Polkadot (via parachains)

ink! (Rust-based); EVM parachains like Moonbeam also run Solidity

Runs atop Substrate-based parachains; permissionless deployment

Parachain apps ; Prototyping

Move

Object-centric: transactions mutate owned objects, enabling parallel processing

NFTs ; Gaming ; DeFi

Bitcoin Script

Limited, not Turing-complete; enforces spending conditions only

Multisignature wallets ; Timelocks ; Layer-2 protocols

Who writes smart contracts and uses them?

Developers write and deploy smart contracts; anyone with the right tooling and enough of a network’s native token to cover deployment costs can do it, and deployment doesn’t require permission from the underlying network. Once a contract is live, anyone can interact with it—usually through an app’s interface rather than by writing code directly. A person swapping tokens, minting an NFT, or voting in a DAO is triggering smart contract execution, typically without needing to understand the underlying language or runtime.

Token standards

Many assets described as “tokens” are smart contracts that follow a shared standard, which lets wallets and apps interact with any compliant token the same way. On Ethereum and other EVM chains, ERC-20 is the standard for fungible tokens, including most stablecoins and utility tokens, and ERC-721 is the standard for NFTs, where each token is unique. Other networks have their own equivalents—Solana’s SPL token standard, for example—built for their respective execution models.

What do smart contracts power?

Across ecosystems, smart contracts are the engine behind apps: DeFi protocols for lending, borrowing, and trading; NFT and digital asset marketplaces; and DAOs whose governance rules live in code rather than in a company’s internal policy. The specific implementation varies by network, but the underlying pattern—code that enforces an agreement without a middleman—is consistent.

Why do smart contracts exist?

Smart contracts exist to remove the need for a trusted intermediary to enforce an agreement. Instead of relying on a bank, an escrow agent, or a platform operator to hold funds and follow through on a set of rules, the rules are encoded directly and execute the same way for everyone who interacts with the contract. That’s the property that makes programmable, self-custodial finance, digital ownership, and blockchain governance possible at scale—regardless of which network hosts the code.

Token approvals and safety

Using an app often means granting a smart contract a token approval—permission to move a specific token on your behalf. This is normal, but it’s also a common attack vector, because a malicious contract can request an approval that lets it move more than a user intended. A token approval can be limited to a specific amount or unlimited. MetaMask Extension displays the full token approval scope—including the contract address and whether the approval is limited or unlimited—before signing, which lets a user review it first. Our guide ontoken approvals covers how to review and revoke them.

Smart contract risks

  • Bugs are permanent: immutable code with a flaw generally can’t be patched after deployment.

Bugs are permanent: immutable code with a flaw generally can’t be patched after deployment.

  • Audits reduce but don’t eliminate risk: audited contracts have still been exploited.

Audits reduce but don’t eliminate risk: audited contracts have still been exploited.

  • Malicious contracts exist on every network that supports them, not just one network.

Malicious contracts exist on every network that supports them, not just one network.

Frequently asked questions about smart contracts

  • A smart contract is self-executing code stored on a network that runs automatically when its conditions are met, without an intermediary.

A smart contract is self-executing code stored on a network that runs automatically when its conditions are met, without an intermediary.

  • No. Ethereum was the first major general-purpose smart contract platform, launching in 2015, but smart contracts now run on many networks, including Solana, Cardano, Polkadot, and Sui, each with its own language and execution model.

No. Ethereum was the first major general-purpose smart contract platform, launching in 2015, but smart contracts now run on many networks, including Solana, Cardano, Polkadot, and Sui, each with its own language and execution model.

  • The blockchain network determines what programming language a given smart contract is written in. Ethereum and other EVM networks mostly use Solidity or Vyper; Solana uses Rust, often with the Anchor framework; Cardano uses Plutus (built on Haskell); Polkadot parachains use ink! (built on Rust); and Sui uses Move.

The blockchain network determines what programming language a given smart contract is written in. Ethereum and other EVM networks mostly use Solidity or Vyper; Solana uses Rust, often with the Anchor framework; Cardano uses Plutus (built on Haskell); Polkadot parachains use ink! (built on Rust); and Sui uses Move.

  • By default, no—deployed code is immutable. Some contracts are specifically built with upgrade mechanisms, but that adds complexity and its own risks.

By default, no—deployed code is immutable. Some contracts are specifically built with upgrade mechanisms, but that adds complexity and its own risks.

  • The technology is well established across multiple networks, but individual contracts can contain bugs or be malicious. Reviewing token approvals and sticking to audited apps reduces risk.

The technology is well established across multiple networks, but individual contracts can contain bugs or be malicious. Reviewing token approvals and sticking to audited apps reduces risk.

  • Executing code on blockchain networks consumes computing resources from the network’s validators or miners, so networks charge a network fee for it. The fee structure differs by network, but the principle—paying for the computation you use—is common to all of them.

Executing code on blockchain networks consumes computing resources from the network’s validators or miners, so networks charge a network fee for it. The fee structure differs by network, but the principle—paying for the computation you use—is common to all of them.

  • MetaMaskMetaMask, formerly Consensys Software Inc, is the world's largest self-custodial financial platform, giving people a single place to hold, spend, save and grow their money across both crypto and traditional assets. The company is building the consumer platform where that happens, bringing payments, savings, investing and digital assets together in one seamless experience. Having grown from the world's most widely used self-custodial wallet, MetaMask gives users direct control over their money and assets, with reach across approximately 190 countries. MetaMask has played a foundational role in Ethereum's growth since 2016. Today, MetaMask sits at the center of the onchain economy, building the operating system for Open Money and putting people in full control of their financial lives.Read all articles

MetaMask, formerly Consensys Software Inc, is the world's largest self-custodial financial platform, giving people a single place to hold, spend, save and grow their money across both crypto and traditional assets. The company is building the consumer platform where that happens, bringing payments, savings, investing and digital assets together in one seamless experience. Having grown from the world's most widely used self-custodial wallet, MetaMask gives users direct control over their money and assets, with reach across approximately 190 countries. MetaMask has played a foundational role in Ethereum's growth since 2016. Today, MetaMask sits at the center of the onchain economy, building the operating system for Open Money and putting people in full control of their financial lives.

  • DEVELOPERSHow to swap and bridge tokens with MetaMask Agent Wallet: 9 key tipsYour agent can swap or bridge tokens from one sentence. Understand how it fills from quotes, slippage, routes, and more.

How to swap and bridge tokens with MetaMask Agent Wallet: 9 key tips

Your agent can swap or bridge tokens from one sentence. Understand how it fills from quotes, slippage, routes, and more.

  • GUIDESTop crypto swaps plaftorms in 2026Crypto swaps platforms exchange one token for another on blockchain networks through a single DEX, an aggregator, or a wallet-native swap.

Top crypto swaps plaftorms in 2026

Crypto swaps platforms exchange one token for another on blockchain networks through a single DEX, an aggregator, or a wallet-native swap.

  • GUIDESRWA risks and due diligenceA tokenized real-world asset can lose value even when the asset behind it is sound. The risks sit in the structure around the token—how it's backed, who holds it, and whether you can redeem it.

RWA risks and due diligence

A tokenized real-world asset can lose value even when the asset behind it is sound. The risks sit in the structure around the token—how it's backed, who holds it, and whether you can redeem it.

What this article says

Something is unclear? Ask about the article — I will explain in plain words.

Do not want to dig deeper? We will sort it out for you.