πŸš€ Premium Banner Placement β€” Reach 100K+ daily crypto readersAdvertise with us β†’
LIVE
BTCβ€”ETHβ€”SOLβ€”BNBβ€”XRPβ€”ADAβ€”AVAXβ€”DOGEβ€”LINKβ€”DOTβ€”MATICβ€”ATOMβ€”LTCβ€”TRXβ€”TONβ€”BTCβ€”ETHβ€”SOLβ€”BNBβ€”XRPβ€”ADAβ€”AVAXβ€”DOGEβ€”LINKβ€”DOTβ€”MATICβ€”ATOMβ€”LTCβ€”TRXβ€”TONβ€”
β€”β–²0.0%
Web3

What Is a Smart Contract? Code That Runs Itself

4 min readGuide
What Is a Smart Contract? Code That Runs Itself

A smart contract is a small program that lives on a blockchain and runs exactly as it was written, without anyone pressing a button. You send it a transaction, it checks the conditions, and it moves the money or updates the record on its own. Ethereum was the first big network built to run smart contracts, and most of them still live there.

How is a smart contract like a vending machine?

A vending machine holds the goods, the price list and the rules in one box. Put in the right coins, press the right button, and the can drops. No shopkeeper decides whether you deserve it, and nobody can quietly change the price while your hand is in the slot. A smart contract works the same way, except the goods are tokens and the box is a public network. Anyone can read the rules before using it, and once a contract is published those rules normally cannot be edited at all.

What do smart contracts actually do today?

Plenty of things you may already have used:

  • Swapping. Uniswap is a set of contracts that hold pots of two tokens and trade against them at a price set by a formula.
  • Lending. Aave holds deposits, lends them out, and takes the collateral automatically when a loan no longer has enough behind it.
  • Issuing. Stablecoins such as Tether, and the tokens behind most NFTs, are contracts keeping a list of who owns how much.

What can go wrong?

Two things, mainly. A contract does what its code says, not what its authors meant, so a mistake in the code is a mistake in the money, and there is no support line to reverse it. And a contract can be written to be unfair on purpose: a token that only its creator is allowed to sell, for example. The code is public, but reading it takes skill, which is why most people stay with contracts that have been audited and used heavily for years.

Before you sign anything, look at what your wallet is really asking. MetaMask shows you the contract address and the permission you are granting, and a request for unlimited access to a token you barely hold is worth cancelling. Start with well-known contracts, small amounts, and a test transaction.

← All guides