Learning Hub
Smart Contracts: The Code That Powers Web3

Smart Contracts: The Code That Powers Web3

If you’ve explored DeFi, NFTs or Web3 identities, you’ve already used smart contracts, whether you knew it or not. They’re the engine behind almost everything in Web3. The good news: the idea behind them is simpler than the name suggests.

What Is a Smart Contract?

A smart contract is a program that lives on a blockchain and runs automatically when certain conditions are met.

The easiest way to picture one is a vending machine. You put in the right amount, press a button and get your snack. There’s no cashier checking your money or deciding whether to hand it over. The rules are built into the machine, and it follows them every time.

Smart contracts work the same way:

  • The rules are written in code. The contract spells out exactly what happens and when.
  • It runs on its own. Once the conditions are met, the contract carries out the action automatically, without anyone stepping in.
  • It’s hard to change. Once a contract is on the blockchain, its code usually can’t be edited. Some contracts are built so their developers can upgrade them, which is worth knowing before you use one.

Why Smart Contracts Matter

Normally, when two parties make a deal, they rely on someone in the middle, like a bank, a lawyer or a platform, to make sure everyone keeps their word. Smart contracts replace that middleman with code.

  • No one controls the outcome. The contract runs on a decentralized network, so no single company can change the terms or block the result.
  • It’s automatic. If the conditions are met, the action happens. No waiting on approvals, no paperwork.
  • It’s transparent. Every interaction is recorded on the blockchain, so anyone can verify what happened.

That’s why people call smart contracts “trustless.” You don’t need to trust the other party, or a company in between. You can rely on the code.

Where You’ll Find Smart Contracts

Decentralized Apps (dApps)

Instead of running on one company’s servers, dApps run on smart contracts spread across a blockchain network. When you connect your wallet to a dApp and take an action, you’re interacting with its smart contracts directly.

DeFi

In decentralized finance, smart contracts handle the jobs a bank normally would. They power token swaps, lending, borrowing and staking, all following rules written in code instead of a bank’s policies.

NFTs and Digital Ownership

NFTs are unique digital assets, like artwork, collectibles or digital identities. Smart contracts record who owns each one and control how it can be transferred. Because that record is on the blockchain, anyone can verify an NFT is authentic and who owns it.

Where Smart Contracts Run

Not every blockchain supports smart contracts, and those that do each work a little differently.

  • Ethereum was the first major blockchain built for smart contracts and is home to the largest community of Web3 developers and apps.
  • Stacks brings smart contracts to Bitcoin. Bitcoin wasn’t designed for complex programs, so Stacks runs them on a separate layer that’s anchored to Bitcoin. Learn more about Bitcoin Layer 2s.
  • Other networks, like Solana and Polygon, focus on faster transactions or lower fees.

A Quick Word on Risk

Smart contracts do exactly what their code says, and that includes any mistakes in it. If a contract has a bug, or was written to trick people, it will still run as written, and as you learned in Irreversible Actions, confirmed transactions can’t be undone.

A few habits help:

  • Stick to well-known apps with a track record.
  • Read what your wallet asks you to approve before you sign.
  • Be cautious with apps asking for broad or unlimited access to your tokens.

How .locker Uses Smart Contracts

Your .locker identity is powered by smart contracts. When you claim a .locker name, ownership is recorded on the blockchain and managed by contract code, not by a company’s private database.

  • Ownership is on the blockchain. Your name is tied to your wallet, and anyone can verify it’s yours.
  • You’re in control. You manage your identity from your own wallet, including updating your profile and transferring your name.
  • Key steps are automated. Contract logic handles things like registration, so there are fewer manual steps and less room for error.

New .locker identities live on Ethereum. Identities claimed before September 1, 2026, were minted on Bitcoin through Stacks, and both are powered by smart contracts.

The Bottom Line

Smart contracts let people make deals, move money and own digital assets without relying on a middleman. They’re behind DeFi, NFTs, dApps and your Web3 identity. Once you understand them, a lot of Web3 starts to make sense.

Back to User Guides