Lesson 3 · Beginner

Smart Contracts 101

5 min read Builds on: Wallets & Private Keys

Code that holds money and follows rules

A smart contract is a program deployed to a blockchain. Once it's live, its code can't be secretly changed, and every interaction with it — every deposit, swap, or withdrawal — is recorded permanently. That combination (public rules, tamper-resistant execution) is what lets strangers use the same financial app without needing to trust each other, or the company that wrote it.

An everyday analogy

Think of a vending machine. You don't need to trust the person who owns it — you trust that inserting the right coin and pressing the right button reliably gives you the snack. A smart contract works the same way: send it the right transaction, and it executes the same logic every time, for everyone, with no human approving each request.

What this looks like in DeFi

  • A lending contract holds deposited assets and automatically calculates interest owed.
  • A swap contract holds two token pools and uses a formula to price trades between them.
  • A staking contract locks tokens for a period and releases rewards on a schedule.
Key idea "Code is law" is a simplification — contracts can still have bugs. Auditing and battle-testing matter, because unlike a bank, there's usually no customer support line to reverse a mistake.

Reading a transaction

When you approve an action in your wallet — say, connecting to this site or swapping a token — you're signing a transaction that will call a specific smart contract function. Your wallet lets you review what you're signing before you approve it, which is why it's worth reading prompts carefully rather than clicking through them.