BR Academy
0%
Smart Contracts and Tokens·Lesson 21 of 25·12 min

What Are Smart Contracts?

The Concept

Everything covered so far — blocks, keys, transactions, consensus — describes a system for moving a scarce digital asset between accounts according to fixed rules anyone can verify. A smart contract takes that same idea and generalizes it: instead of a blockchain only running one hardcoded set of rules (like "balances can only decrease if signed by the owner"), a smart contract is a program, stored on the blockchain itself, whose code is the rules — and whose execution is enforced by the same decentralized network of nodes that validates ordinary transactions.

The name is a bit misleading — a smart contract isn't "smart" in any AI sense, and it isn't a legal contract either. It's closer to a vending machine: you put in the right input (send it a transaction with specific data and the right amount of currency), and it automatically executes exactly the logic written into it — no human reviews the request, no company approves it, no one can change their mind halfway through. If the code says "when this condition is met, release these funds to that address," that is precisely and only what happens, every single time, verified independently by every node on the network the same way a regular transaction is verified.

This matters because it lets people build agreements and applications that don't require trusting a counterparty or a middleman. Two strangers who've never met can enter into an arrangement — an auction, a loan, an insurance payout, a token swap — where the code itself guarantees the outcome, rather than requiring either party to trust the other, or trust a company sitting between them. Ethereum was the first major blockchain purpose-built around this idea; its nodes run a shared "world computer" (the Ethereum Virtual Machine, or EVM) that executes smart contract code identically on every node, keeping everyone's view of each contract's state in sync, the same way they stay in sync on account balances.

Smart contracts are deployed to specific addresses on the blockchain, just like a wallet address, except instead of being controlled by a private key, the address is controlled entirely by its code. Once deployed, that code typically cannot be changed (though some contracts are deliberately designed with upgrade mechanisms, usually through a separate proxy pattern that itself must be disclosed and trusted) — which is a double-edged sword: it means no one can secretly alter the rules after you've trusted them, but it also means a bug written into the contract is usually permanent and, if it allows funds to be stolen, unrecoverable. This is why serious projects pay for professional security audits before deploying a contract that will hold real value, and why "audited by [firm]" has become a meaningful signal in the ecosystem, not just marketing language.

It's also worth distinguishing a smart contract from a traditional computer program: a normal program runs on one company's servers, which that company can shut down, modify, or censor at will. A smart contract, once deployed, runs for as long as the underlying blockchain exists, cannot be taken offline by any single party, and executes for anyone who sends it a valid transaction — including people the original deployer never anticipated or approved.

Worked Example

Imagine a simple smart contract for a crowdfunding campaign, written conceptually:

contract Crowdfund:
    goal = 10 ETH
    deadline = block 500000
    raised = 0
    contributions = {}

    function contribute(amount):
        require(current_block < deadline)
        contributions[sender] += amount
        raised += amount

    function claim_or_refund():
        if raised >= goal:
            send raised amount to campaign_owner
        else:
            refund each contributor their contribution

Dozens of strangers can send ETH to this contract's address before the deadline, each contribution automatically recorded. No campaign owner can touch the funds early, and no contributor needs to trust the campaign owner's promises — the contract's own code, executed identically by every node, guarantees that funds either go to the owner (if the goal is met) or get refunded (if it isn't). Nobody needs a bank, a lawyer, or a platform like Kickstarter sitting in the middle holding the money and making the decision.

Now suppose the deadline passes with only 7 ETH raised. Anyone — not just the contributors — can call claim_or_refund(), and the contract will loop through its contributions record and send each contributor's exact amount back to their own address. No customer service ticket, no dispute process, no waiting for a company to process refunds: the outcome was guaranteed the moment the contract was deployed, before a single contribution arrived.

Exercise

In two or three sentences, explain why the crowdfunding contract above removes the need for contributors to trust the campaign owner — and then identify one risk this model still carries (hint: think about what happens if the contract's code itself has a bug, and who could catch that bug before money is at stake). Then, in one more sentence, name one real-world agreement (outside of crowdfunding) that you think could be redesigned as a smart contract, and one that you think could not — and briefly say why not.

Recap

  • A smart contract is code stored on a blockchain that executes automatically and identically on every node when its conditions are triggered.
  • It replaces trust in a counterparty or middleman with trust in verifiable, unchangeable code, enforced by the same network that validates ordinary transactions.
  • That same permanence is a risk: bugs in deployed contract code are usually unfixable and can be exploited exactly as written, which is why audits matter before real value is at stake.