Skip to main content
This website uses essential cookies required for its operation. Course content and all third-party embedded materials are accessible only to registered users. To manage your consent preferences, please register and log in.
x

Section outline

  • Lesson 3: Understanding Smart Contracts – Code That Executes unlocks the most powerful layer of blockchain, transforming it from a simple ledger into a global, decentralized computer.

    You will learn what smart contracts are—self-executing code that automatically enforces agreements without lawyers or courts—and explore the "Code is Law" philosophy through the infamous DAO hack of 2016, where a $60 million bug forced the Ethereum community to choose between immutability and human intervention.

    You will understand how the Ethereum Virtual Machine (EVM) ensures determinism (same inputs produce same outputs across all nodes), why every computation costs gas (to prevent infinite loops, spam, and compensate validators), and how oracles act as bridges to bring real-world data onto the blockchain. You will also explore the anatomy of an NFT as an ERC-721 smart contract, understanding that an NFT is a unique token ID recorded on-chain, not the image itself.

    Through a smart contract flowchart activity and a video on gas and oracles, you will complete a group forum debate on whether a buggy contract's outcome should stand or human authorities should intervene. 

    • Question:
      "A smart contract for a community fund has a bug that accidentally sends funds to the wrong address. The person who received the funds refuses to return them, saying 'Code is Law – I followed the rules.' Should the community intervene to recover the funds? Why or why not?"
       

      Share with a partner, then we'll hear 2-3 perspectives. 

    • Time: 25-30 minutes

      In pairs, learners design a simple smart contract for a community project and map the process in a flowchart. Below your flowchart, write 2-3 sentences explaining:

      1. What triggers the smart contract to start?

      2. What condition must be met for execution?

      3. What happens automatically when the condition is met?

      Select one of the following community project scenarios, or create your own (must be approved by facilitator).

      Scenario A – Volunteer Milestone Funding

      "A community garden project requires volunteers to sign up for weekend shifts. The project has a budget of 10 ETH. When 10 volunteers have signed up, the smart contract should automatically release 50% of the budget (5 ETH) to the garden supply wallet."

      Scenario B – Matching Grant

      "A youth education program runs a fundraising campaign. A donor has pledged a matching grant: for every 1 ETH raised from the community, the donor will contribute 0.5 ETH. When the community raises 5 ETH, the donor's 2.5 ETH should be released automatically."

      Scenario C – Milestone-Based Funding

      "A social enterprise building a community water well has a budget of 20 ETH. Funds should be released in three stages: 25% when the land is purchased (verified by a government land registry oracle), 50% when construction reaches 50% completion (verified by a project manager's signature), and 25% when the well passes water quality testing (verified by a testing lab oracle)."

      Scenario D – Escrow for Services

      *"A local artist is commissioned to paint a community mural for 3 ETH. The client deposits the 3 ETH into the smart contract. When the artist submits proof of completion (photo upload + GPS coordinates verified by oracle), the contract releases 2.5 ETH to the artist. The remaining 0.5 ETH is released after the client confirms satisfaction within 7 days. If no confirmation, funds auto-release."*

      Scenario E – Create Your Own

      Design a smart contract for a community project relevant to your own experience. Must include at least one condition and one automatic execution. Get facilitator approval before starting.

    • Gas and fees.pptx by Jovan Karamachoski

    • Watch & Learn (10 minutes)

      Video: "Ethereum Gas Explained" – Finematics (8 min)

      Link:

      Alternative: "What is Gas in Ethereum?" – Simply Explained (5 min)

      Link:

      While watching, note:

      1. What happens if you set gas limit too low?
      2. Why do complex contracts cost more gas?
      3. How can you reduce gas costs?

      Post-Video Discussion (5 minutes)

      Questions:

      1. What happens if you set gas limit too low?
        • Transaction fails (runs out of gas)
        • You still pay for gas used up to limit
        • Failed transactions still cost money!
      2. Why do complex contracts cost more gas?
        • More operations (storage writes, loops, external calls)
        • Each operation consumes gas
      3. How can you reduce gas costs?
        • Use Layer 2 (Arbitrum, Optimism, Polygon)
        • Transact during off-peak hours
        • Use efficient dApps (optimized contracts)
        • Bundle transactions (when possible)
    • Group Forum Discussion

      Scenario:
      "A community savings group uses a smart contract where members deposit monthly. The contract has a bug: the withdrawal function doesn't check if the requester is the actual owner – it only checks if the requester's address starts with '0x123'. By chance, an attacker's address matches. They drain 50% of the funds. The community discovers the bug immediately after."

      Debate question:
      "Should the 'code is law' outcome stand (attacker keeps funds), or should the community hard-fork the blockchain to revert the transaction?"

      Requirements:

      • Initial post (150+ words): Your position with clear reasoning
      • One reply (100+ words): Engage with a different position

      Guiding Questions:

      📜 Immutability: Does reverting the transaction break the promise of blockchain?

      🔥 The DAO precedent: Ethereum hard-forked to revert the $60M hack. Is this case similar or different?

      ⚖️ Intent vs. code: Was the community's intent clearly violated?

      🛡️ Precedent: If you revert this, where do you draw the line? What about future "accidents"?

      👥 Community governance: Who decides? A vote? A foundation? The developers?

      💰 Practicality: Hard forks are disruptive and controversial. Is it worth it for 50% of funds?

      Use at least 2 concepts from the lesson in your post.

    • Optional, self-check quiz to test your understanding (Not Graded)

Credits …
NFT ❯
ⓘ Lab Description