Quick answer

A smart contract is a program stored on a blockchain that runs automatically when someone sends it a transaction, following rules written in its code. Nobody can change how it behaves for one user and not another, and every node on the network checks that it ran correctly. If you are asking what is a smart contract in practice, think of the logic behind a token, a swap pool or a lending market.

Despite the name, a smart contract is not a legal agreement and is not "smart" in the sense of making judgments. It is deterministic code: the same input always produces the same output. That predictability is its strength, and its inability to adapt or undo mistakes is its main weakness.

What is a smart contract in simple terms?

The idea of a self-executing contract was described by computer scientist Nick Szabo in the 1990s, using a vending machine as the example. You insert the right amount, press a button and the machine delivers a snack. No clerk decides whether you deserve it; the rules are built into the machine.

A blockchain makes this idea work for digital value. Because the blockchain keeps a shared record that no single party controls (see our simple explanation of blockchain), a program stored on it can hold and move assets according to its rules, and everyone can verify that it did so.

Bitcoin supports a limited scripting language for conditions such as multisignature spending. Ethereum was designed to run general-purpose programs, which is why the Ethereum smart contract became the standard model that many other networks copied. Our comparison of Bitcoin vs Ethereum covers this design difference in more detail.

How smart contracts work, step by step

  1. Writing: a developer writes the contract in a language such as Solidity or Vyper (on Ethereum and compatible chains) or Rust (on some other networks).

  2. Deployment: the code is compiled into bytecode and sent to the network in a special transaction. The contract receives its own contract address, and from then on its code is public.

  3. Calling: a user or another contract sends a transaction to that address, naming a function and passing inputs, for example "swap 1 token A for token B".

  4. Execution: every validating node runs the same code with the same inputs. The sender pays a network fee (gas) for the computation and storage used.

  5. Result: if all conditions pass, the state changes are recorded in a block. If any condition fails, the whole transaction reverts, though the fee for the work done is usually still paid.

One detail surprises many beginners: smart contracts never act on their own. They wake up only when a transaction calls them. Scheduled or automatic actions require an outside party, often a bot or keeper service, to send that transaction.

What smart contracts are used for

Most of what people do on-chain beyond simple transfers runs through smart contracts. The apps built on them are called dapps (decentralized applications), which combine on-chain contracts with a website or wallet interface.

  • Tokens: standards such as ERC-20 define how a token tracks balances and transfers. The difference between native coins and contract-based tokens is explained in our coin vs token guide.

  • Exchanges and lending: decentralized exchanges, lending markets and other building blocks of decentralized finance are collections of contracts.

  • NFTs: contracts record who owns each unique token and handle transfers.

  • Governance: DAOs use contracts to count votes and execute approved proposals.

  • Shared custody: multisignature wallets require several approvals before funds move.

Gear mechanism at the center linked to tokens, a swap, a liquidity pool, an NFT frame, a ballot box and an oracle, the main uses of smart contracts

What smart contracts cannot do

Understanding the limits is as important as understanding the uses.

They cannot see the outside world. A contract cannot check the weather, a sports score or the price of an asset on its own. It relies on oracles, services that publish external data on-chain. If an oracle reports wrong data, the contract acts on wrong data.

They cannot fix mistakes. If you send tokens to the wrong address or approve a malicious contract, the code does not know you did not mean it. There is no customer support built into a contract.

They are not automatically legal agreements. Code enforces what it says, not what the parties intended. Whether an on-chain arrangement is enforceable in court depends on local law.

They are not always unchangeable. Many projects use upgradeable designs, where an admin key or governance vote can replace the logic. This allows bug fixes but also means users trust whoever controls the upgrade.

Smart contract risk for users

Contract risk is the possibility of losing funds because of how a contract is written or controlled. The main forms are:

  • Bugs and exploits: errors in logic, such as reentrancy or faulty math, have led to large losses even in audited projects. An audit reduces risk but does not remove it.

  • Oracle manipulation: attackers sometimes distort a price feed to borrow or withdraw more than they should.

  • Admin and upgrade powers: a team with control over upgrades or pausing can change rules, and a stolen admin key can be catastrophic.

  • Malicious contracts: scam tokens and fake apps use contracts designed to take approvals or block selling.

  • Approval abuse: unlimited token approvals let a contract move your tokens later. Our guide to token approvals shows how to review and revoke them.

Crypto assets and the apps built around them can be volatile and experimental, so do your own research before using any new protocol.

Checklist before interacting with a smart contract

  1. Get the app link and contract address from the project's official documentation or verified channels, not from ads or direct messages.

  2. Check that the contract is verified on a block explorer, so its source code is public.

  3. Look for audits, how long the contract has been live, and whether it is upgradeable and who controls upgrades.

  4. Read every wallet prompt. A swap, a transfer, an approval and a signature request are different actions with different consequences.

  5. Approve only the amount you need, and test with a small amount when using a new app.

FAQ

What is a smart contract in one sentence?

It is a program stored on a blockchain that automatically executes its rules when a transaction calls it, with the result verified by the network.

Can a smart contract be changed after deployment?

The deployed code itself cannot be edited, but upgradeable designs can point to new logic through a proxy contract. Whether that is possible depends on how the project was built.

Do I pay to use a smart contract?

Yes, calling a contract that changes the blockchain state requires a network fee. Reading data from a contract is usually free.

Are audited smart contracts safe?

Audits lower the chance of known bug types but cannot guarantee safety. Audited contracts have still been exploited, so treat an audit as one signal among several.

Does Bitcoin have smart contracts?

Bitcoin supports simpler scripts for conditions such as multisignature and time locks, but it is not designed for the general-purpose contracts common on Ethereum.